az command stopped working on my automation

Marcos Guedes 1 Reputation point
2021-11-18T19:12:45.14+00:00

Hi,

I have a runbooks that it worked until november 12, 2021.

But, today, when I went to test again, the same runbook doesn't work.

When it execute the following error occurs:

"az : The term 'az' 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. At line:3 char:1 + az login --service-principal -u "XXb0cdb1-XXdc-Xxf6-a45c-fedaa11XXXXX ... + ~~ + CategoryInfo : ObjectNotFound: (az:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException"

Can anyone help me with this?

My source code:

Param($subdomain)

az login --service-principal -u "XXX8f1d7-11Xx-Xe75-9dXX-0afc6cd64cXx" -p "XXr5asIXXXXvDenKnF1PYV6Kvf.o3rMiU~" --tenant "Xxfcf155-XXXX-40e5-xx74-f23b4501XXxX"

az network dns record-set txt add-record --resource-group "xxxResourceGroup" --zone-name xxx.com.br --record-set-name "asuid.$($subdomain)" --value "XXX"

az network dns record-set cname set-record --resource-group "xxxResourceGroup" --zone-name xxx.com.br --record-set-name $subdomain --cname xxx.azurewebsites.net

az webapp config hostname add --webapp-name xxx--resource-group "xxxResourceGroup" --hostname "$($subdomain).xxx.com.br"

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,368 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. tbgangav-MSFT 10,426 Reputation points Moderator
    2021-11-19T15:06:42.757+00:00

    Hi @Marcos Guedes ,

    Short answer: Create a new runbook with runtime version as 7.1 (preview) and then copy paste your runbook content into it then you can avoid the error.

    Long answer: I have tried to reproduce the issue by creating a runbook with runtime version as 5.1 and another runbook with runtime version as 7.1(preview). It has given the same error as you mentioned when the runtime is 5.1 and it worked successfully when the runtime is 7.1(preview).

    Illustration:

    Runbook with runtime version 5.1:

    150969-image.png

    151052-image.png

    Runbook with runtime version 7.1(preview):

    151053-image.png

    151008-image.png

    For more information with regards to runtime versions 5.1 and 7.1(preview), you may refer this Azure document.

    If you have additional question: When will we support Az CLI in runbooks?
    Answer: We will be bringing in the Az CLI support to Azure Automation post Powershell 7 support which is planned around CY21 Q4 timeframe. This is the source of the provided information.


  2. K, Leon 1 Reputation point
    2022-01-06T09:53:03.027+00:00

    Hey There,

    i can confirm exactly same behavior here. I was so happy, that we can use the "az" command and then wrote a several automations runbook using the Documentations. until november 12, 2021 it was working fine with the 7.1 Preview. But since then (i think something went wrong including the dependencies and resolving the Aliaces of the Module) not working all Script get the Error mentioned above..

    We really appreciate your help. Or please let us know, if the "az" will be a default alias to use. otherwise we have to rewrite all the scripts from there.

    Please give us feedback as soon as possible.

    Best Regards
    Leon

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.