[英]Issue with Creating New Container Through Azure DevOps AzurePowershell@5 Task
I have an inline script using Azure Powershell@5 task我有一个使用 Azure Powershell@5 任务的内联脚本
- task: AzurePowerShell@5
inputs:
azureSubscription: azureServiceConnection
scriptType: inlineScript
inline: |
$storageAccountKey = Get-AzStorageAccountKey -ResourceGroupName $(resourceGroupName) -Name $(commonStorageName) | Where-Object {$_.KeyName -eq "key1"}
$sacontext = New-AzStorageContext -StorageAccountName $(commonStorageName) -StorageAccountKey $storageAccountKey.Value
New-AzureStorageContainer -Context $sacontext -Name $(processingDirectory)
This is the error that I get:这是我得到的错误:
Cannot bind parameter 'Context'.
无法绑定参数“上下文”。 Cannot convert the "Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext" value of type "Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext" to type "Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext".
无法将类型“Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext”的“Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext”值转换为类型“Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext”。
I know there is another question regarding this same exact error with mismatch Az.Storage versions, but this is an ADO task.我知道关于 Az.Storage 版本不匹配的相同错误还有另一个问题,但这是一项 ADO 任务。 I should not need to fiddle around with installing or importing modules.
我不需要摆弄安装或导入模块。 I also tested this on the Azure CLI and it works.
我还在 Azure CLI 上对此进行了测试,它可以工作。
What am I doing wrong?我究竟做错了什么?
It appears that New-AzureStorageContainer is part of AzureRM PowerShell. New-AzureStorageContainer 似乎是 AzureRM PowerShell 的一部分。 To create a container, you must use New-AzStorageContainer from Az Powershell.
若要创建容器,必须使用 Az Powershell 中的 New-AzStorageContainer。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.