Forum Discussion
Automated backup of Azure DNS Zone records
You can accomplish this with an automation account and runbook. As far as I am aware there is now way baked into the Azure portal to do this natively. It would have to be accomplished by scheduling that script you have outlined. Let me know if you would like some assistance with that and I can point you in the right direction. GregHunter
- nickfletcherJan 14, 2021Copper Contributor
Hi Bryan! I know the post I am replying on is very old but it is exceptionally relevant to what I am currently fighting and I was hoping you could provide some direction.
I have a PowerShell script that I can log into the Azure Cloud Shell and run manually that exports all our public DNS zones and saves them to files. The goal is to get a backup. Obviously a manual backup is less than ideal so I am trying to automate this.
As you recommended, I have been fighting getting this working in an automation account for weeks now. Essentially, it is not recognizing the az command. In an effort to simplify troubleshooting I have created and published a runbook that runs only this (Resource Group name cut intentionally):
az network dns zone list -g %ResourceGroupName%A simple command that should just list the zones in the group. This fails with this error: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:1 char:1 + az network dns zone list -g %ResourceGroupName% + ~~ + CategoryInfo : ObjectNotFound: (az:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundExceptionDo you know if this is supported in an automation account? If not, is there a better way to do this?- hspintoJan 17, 2021
Microsoft
Az CLI is not available in the cloud hosted Automation workers.
You can either:
1) try to download and install Az CLI on the fly with PowerShell before running "az" commands. Of course, you would need first to authenticate with the Run As Account or other service principal.
2) use an Azure VM or a machine on-premises as a Hybrid Worker. Runbooks will run in this machine, which is owned by you and where you can install whatever dependencies are needed. If you want to reuse Run As Accounts inside the worker, you will have to install the Run As certificate.
- nickfletcherJan 18, 2021Copper Contributor
hspinto Just ot make sure I understand option 1 correctly, you mean in the script I am trying to run add the commands to download the Az CLI so it will install in the sandboxed environment each time it runs?
- GregHunterJun 26, 2019Copper Contributor
Hi Bryan,
Do you mean there is 'no' way baked into the portal to do this naively?
Some assistance would be much appreciated! I was hoping to pipe the out of the above command into a blob file using the 'az storage blob upload' command, but I dont think this is possible.
thanks Bryan Haslip