askolotl
askolotl

Reputation: 1006

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?

Upvotes: 4

Views: 6142

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136366

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

Upvotes: 7

Related Questions