We have some old scrips that still use Azure and AzureRm cmdlets. Since we are in the middle of migration to Octopus cloud we are not ready to update our scripts to the new Az module yet, I created a new static worker with Azure and AzureRm modules installed to use. We have old Azure scripts in the second and fourth step of our deployment. All three step works fine except the deployment keeps failing at the same point in the fourth step with the following
July 19th 2022 12:29:46Error
ObjectNotFound: The term ‘Get-AzureEnvironment’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
July 19th 2022 12:29:46Error
At C:\Octopus\Work\20220719172919-7579-2\Octopus.AzureContext.ps1:222 char:33
July 19th 2022 12:29:46Error
-
$AzureEnvironment = Get-AzureEnvironment | Where-Object { ...
I found that we don’t have that statement in our script and it is failing at Octopus.AzureContext.ps1:222 .
Any idea why Octopus is not recognizing the cmdlet at that point but not in other places of our script?
Note: I had followed most of the suggested options from support tickets similar to mine. I have restarted the tentacle service in the worker. I have installed Azure CLI in the worker. I tried installing Az module and Enable-AzureRmAlias -Scope LocalMachine in another worker but that too throwing Azure errors caused by Import Azure module like statements in our script which might need to be changed that we not ready. So I’m focusing on the worker with the old Azure modules.