简体   繁体   English

Azure和Powershell-无法连接到正确的存储帐户

[英]Azure and Powershell - Can not connect to correct storage account

I'm new to both Azure and Powershell. 我是Azure和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. 我正在尝试连接到特定的存储帐户以上传一些文件,但是它一直在选择我的Azure帐户内的另一个存储帐户。

$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' 上面的结果导致容器和我的文件被上传到另一个存储帐户,我们称其为“ 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. 从门户网站上,我可以看到“ myaccountname”的类型为“ Storage account”,“ otherstorageaccount”的类型为“ Storage account(classic)”-我不知道这对结果是否有影响。 Also, I've checked the key and it's correct. 另外,我已经检查了键,它是正确的。

Thanks for any help 谢谢你的帮助

Can you try by passing StorageAccountContext to your calls. 您可以通过将StorageAccountContext传递给您的电话来尝试吗?

$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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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