Hi,
I have 2 AzurePowerShell@5 tasks that both need to run some queries against a CosmosDB Database.
Issue 1:
If I load in the module CosmosDB and run it, all is fine in the first AzurePowerShell@5 task.
When I try and run a query in the second AzurePowerShell@5 it falls over, because it's already loaded. If I remove the install (which has the -force option added) it fails, because it's not already loaded.
Issue 2:
If I load in the first AzurePowerShell@5, and then uninstall at the end of it, it goes through the motions.
If I check for CosmosDB in the second AzurePowerShell@5 task, it still finds it so I try and uninstall it. It then fails:
"No modules were removed. Verify that the specification of modules to remove is correct and those modules exist in the runspace"
This is how it's set up:
- task: AzurePowerShell@5
displayName: Shell1
inputs:
azureSubscription: '$(subscription)'
pwsh: true
ScriptType: 'InlineScript'
azurePowerShellVersion: 'LatestVersion'
Inline: |
Install-Module -Name "CosmosDB" -Force
Import-Module -Name "CosmosDB"
<more lines>
if( Get-Module -Name "CosmosDB" -ListAvailable )
{
Write-Output "Finish task, remove CosmosDB module"
Remove-Module -Name "CosmosDB" -Force -Verbose
}
- task: AzurePowerShell@5
displayName: Shell2
inputs:
FailOnStandardError: true
azureSubscription: '$(subscription)'
azurePowerShellVersion: 'LatestVersion'
pwsh: true
ScriptType: 'InlineScript'
Inline: |
if( Get-Module -Name "CosmosDB" -ListAvailable )
{
Remove-Module -Name "CosmosDB" -Force -Verbose
}
Install-Module -Name "CosmosDB" -Force
Import-Module -Name "CosmosDB"
<some lines>
The remove in the first task is called and with 'verbose' on I can see it removing the libs. I've tried the Install in multiples, in a single pre-call inline script and with removes. I've tried the Install and Remove commands with and without quotes for the name. No difference, it must be obvious, but I can't see what I'm doing wrong. Any info appreciated.