调用 New-AzureStorageTable cmdlet 时 VSTS Release Azure Powershell 任务失败

VSTS Release Azure Powershell task fails when calling New-AzureStorageTable cmdlet

我正在构建一个发布管道,它会在 Azure Table 存储中创建并填充一个 table(如果它尚不存在)。我的 Powershell 文件在我的机器上本地运行,但是当我将它签入 VSTS 并在发布管道中的 'Azure Powershell' 步骤中执行它时,它失败了。

这是 ps1 文件中的相关脚本:

$ctx = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey

$table = Get-AzureStorageTable -Name $tableName -Context $ctx -ErrorAction SilentlyContinue

# Create it if it doesn't exist
if ($table -eq $null) {
    $table = New-AzureStorageTable –Name $tableName –Context $ctx
}    

构建代理引发的错误是

New-AzureStorageTable : Could not load file or assembly 'System.Spatial, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

这是 VSTS Hosted 2017 构建代理(版本 2.126.0)。我可以看到 New-AzureStorageTable cmdlet 在执行我的自定义脚本之前由代理加载。我希望构建代理拥有所有基础资产来支持它提供的 cmdlet。

改为使用 PowerShell 任务或托管代理。

这里有反馈可以投票跟进:New-AzureStorageTable error in Hosted VS 2017 agent