Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Azure Storage via Connection String

I have an Azure Storage (StorageV2), and I want to connect and upload files via Powershell.

However, I want to use the Connection String (which contains a long secret key). So people without a Microsoft account should be able to use the script.

There is the command Connect-AzAccount, but for this, it seems you need to have a Microsoft account.

So how is it possible to connect and upload just with the Connection String and without having a Microsoft account?

like image 705
askolotl Avatar asked Oct 28 '25 09:10

askolotl


1 Answers

Each Cmdlet in Az.Storage module expects a -Context parameter. You can use New-AzStorageContext Cmdlet to set that context and pass that context to the Cmdlet (e.g. for uploading blob).

If you have the connection string for your storage account, you would create a context like:

$ctx = New-AzStorageContext -ConnectionString "your-storage-account-connection-string"

and use it like the following:

Set-AzStorageBlobContent -Context $ctx ...rest of the parameters
like image 182
Gaurav Mantri Avatar answered Oct 31 '25 01:10

Gaurav Mantri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!