简体   繁体   中英

Azure and Powershell - Can not connect to correct storage account

I'm new to both Azure and Powershell. I'm trying to connect to a specific Storage Account to upload some files, but it keeps selecting another storage account that's within my Azure account.

$StorageContainerName = "mycontainername"
$StorageAccountName = "myaccountname"
$StorageAccountKey = "thisisafakekey=="

New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
New-AzureStorageContainer $StorageAccountName -Name $StorageContainerName -Permission Off
Get-ChildItem –Path C:\documents\* | Set-AzureStorageBlobContent -Container $StorageContainerName

The above results in the container and my files being uploaded to another storage account, let's call it 'otherstorageaccount'

From the portal I can see that 'myaccountname' is of type 'Storage account' and 'otherstorageaccount' is of type 'Storage account (classic)' - I don't know if this has any bearing on the outcome. Also, I've checked the key and it's correct.

Thanks for any help

Can you try by passing StorageAccountContext to your calls.

$StorageContainerName = "mycontainername"
$StorageAccountName = "myaccountname"
$StorageAccountKey = "thisisafakekey=="

$ctx = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
New-AzureStorageContainer $StorageAccountName -Name $StorageContainerName -Permission Off -Context $ctx
Get-ChildItem –Path C:\documents\* | Set-AzureStorageBlobContent -Container $StorageContainerName -Context $ctx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM