简体   繁体   English

通过 Azure DevOps AzurePowershell@5 任务创建新容器的问题

[英]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.

相关问题 从 Azure SQL InlineSqlTask 任务创建一个 output 变量 azure devops - creating an output variable azure devops from the Azure SQL InlineSqlTask task Azure Devops:在 Devops 管道任务中通过 Azure CLI 进行模型注册和打包 - Azure Devops: Model Register and package through Azure CLI in Devops pipeline Task AzurePowerShell 任务找不到文件路径 - AzurePowerShell task cannot find filePath Azure 来自 Azure DevOps YAML 管道的容器实例创建问题 - Azure Container Instance creation issue from Azure DevOps YAML pipeline Azure Devops 任务版本 - Azure Devops task versions Azure CLI 从任务创建新分支 - Azure CLI creating a new branch from a task 使用Azure-Cli创建新的容器 - Creating a new Container with Azure-Cli Azure DevOps AzureCLI 任务与 scriptPath 选项未能通过身份验证创建 Azure 容器实例 - Azure DevOps AzureCLI task with scriptPath option failed to authenticate to create Azure Container Instance Azure DevOps -- 使用Docker-Compose任务部署到Azure容器实例 - Azure DevOps -- using Docker-Compose task to deploy to Azure Container Instances 通过 devOps 部署时,Azure 策略不会为托管标识创建角色 - Azure policy not creating roles for managed identity when deployed through devOps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM