调用New-AzureStorageTable cmdlet时,VSTS版本Azure Powershell任务失败

问题描述 投票:1回答:1

我正在构建一个发布管道,如果它尚不存在,则在Azure表存储中创建并填充表。我的Powershell文件在我的机器上本地运行,但是当我将其检入VSTS并在“Azure Powershell”步骤中的Release管道中执行它时,它会失败。

以下是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 azure azure-pipelines azure-powershell azure-pipelines-release-pipeline
1个回答
0
投票

请改用PowerShell任务或托管代理。

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

© www.soinside.com 2019 - 2024. All rights reserved.