VSTS Release Azure Powershell task fails when call

2019-08-02 02:35发布

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.

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
}    

And the error raised by the build agent is

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.

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.

1条回答
Explosion°爆炸
2楼-- · 2019-08-02 03:22

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

查看更多
登录 后发表回答