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.