I have an Azure storage account with Blob containers and folders (also named containers?) within these blob containers. I have an Account Name and Account Key to access it and I can upload files using Microsoft Azure Storage Explorer. I have been searching for a simple script to upload files to a specific blob container but I have been able to find one. Uninstallig the RM-modules and installing the AZ-modules was already a challenge. The examples all seem to be very complicated (security is not an issue for this project) and I just cannot get them to work and I am newby to the subject.
Can anyone share a simple line of powershell script with me to do this?
I tried to upload files to a specific blob container by using below PowerShell script and got the result successfully:
Connect-AzAccount
$ctx = New-AzStorageContext
-StorageAccountName 'YourStorageAccountName'
-StorageAccountKey 'YourStorageAccountKey' -Protocol Https
Set-AzStorageBlobContent
-File "C:\Users\Downloads\YourFileName" ` //Your file path
-Container YourContainerName
-Blob "YourFileName" `
-Context $ctx
The file got uploaded to the blob container successfully like below:
To confirm the above, check in the Portal whether the file is uploaded or not like below:
Please note that, to run the above script you need Azure modules like Az.Accounts
and Az.Storage
modules. You can refer this MsDoc to install the same.
Reference:
Quickstart: Upload, download, and list blobs - Azure PowerShell - Azure Storage | Microsoft Docs