调用New-AzureStorageTable cmdlet时VSTS Release Azure Powershell任务失败 [英] VSTS Release Azure Powershell task fails when calling New-AzureStorageTable cmdlet
问题描述
我正在构建一个发布管道,该管道将创建并填充Azure表存储中的表(如果尚不存在).我的Powershell文件在我的计算机上本地运行,但是当我将其检入VSTS并在"Azure Powershell"步骤中的Release管道中执行它时,该文件将失败.
I am building a release pipeline which creates and populates a table in Azure Table Storage if it doesn't yet exist. My Powershell file runs locally on my machine, but when I check it in to VSTS and execute it in the Release pipeline in an 'Azure Powershell' step it fails.
这是ps1文件中的相关脚本:
Here is the relevant script from the ps1 file:
$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.
This is a VSTS Hosted 2017 build agent (version 2.126.0). I can see that the New-AzureStorageTable
cmdlet is loaded by the agent before executing my custom script. I would expect a build agent to have all the underlying assets to support cmdlets it makes available.
推荐答案
改为使用PowerShell任务或托管代理.
Using PowerShell task or Hosted agent instead.
There is the feedback here that you can vote and follow up: New-AzureStorageTable error in Hosted VS 2017 agent
这篇关于调用New-AzureStorageTable cmdlet时VSTS Release Azure Powershell任务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!