Forum Discussion
Automated backup of Azure DNS Zone records
Hello,
Does anybody know if it is possible to somehow automate the backup of DNS zone records?
I can perform a manual export using the following command but would like it on a schedule, with the output dumped into a azure storage if possible.
az network dns zone export -g myresourcegroup -n contoso.com -f contoso.com.txt
https://docs.microsoft.com/en-us/azure/dns/dns-import-export
cheers
7 Replies
- Bryan HaslipIron Contributor
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
- nickfletcherCopper 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?- hspinto
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.
- GregHunterCopper 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