{"id":4455,"date":"2018-06-18T12:56:58","date_gmt":"2018-06-18T10:56:58","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=4455"},"modified":"2018-06-18T12:58:18","modified_gmt":"2018-06-18T10:58:18","slug":"exporting-azure-resource-manager-templates-with-azure-automation-and-protecting-them-with-azure-backup","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=4455","title":{"rendered":"Exporting Azure Resource Manager templates with Azure Automation, and protecting them with Azure Backup"},"content":{"rendered":"<p>Earlier this week I put together a runbook to backup Azure Resource Manager (ARM) templates for existing Resource Groups. The runbook exports the resource group as a template and saves it to a JSON file. The JSON file is then uploaded to an Azure File Share that can be protected with Azure Backup.<\/p>\n<p>The runbook can be downloaded from here, <a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/PS100-ExportRGConfig.txt\">PS100-ExportRGConfig<\/a>. The runbook format is PowerShell. The runbook might require an Azure PS module upgrade. I have noticed that in some new Azure Automation accounts, the AzureRM.Resources module doesn\u00e2\u20ac\u2122t include Export-AzureRmResourceGroup and needs an update.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-4457\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-300x112.jpg\" alt=\"\" width=\"300\" height=\"112\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-300x112.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-768x287.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-1024x382.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules.jpg 1544w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Inside of the runbook, you need to configure the following variables:<\/p>\n<ul>\n<li>Resourcegrouptoexport , this is the Resource Group you would like to export to a JSON file.<\/li>\n<li>storageRG, this is the name of the Resource Group that contains the file share you want to upload the JSON file to.<\/li>\n<li>storageAccountName, this is the name of the storage account that contains the Azure file share.<\/li>\n<li>filesharename, this is the name of the Azure file share in the storage account. On the Azure file share, there needs to be a directory named templates. You will need to create that directory manually.<\/li>\n<\/ul>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-directory.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-4458\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-directory-300x106.jpg\" alt=\"\" width=\"300\" height=\"106\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-directory-300x106.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-directory-768x271.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-directory.jpg 895w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Parameters.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-4456\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Parameters-300x186.jpg\" alt=\"\" width=\"300\" height=\"186\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Parameters-300x186.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Parameters.jpg 629w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>When you run the runbook you might see warning messages. There might be some cases where the PowerShell cmdlet fails to generate some parts of the template. Warning messages will inform you of the resources that failed. The template will still be generated for the parts that were successful.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Errors.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-4459\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Errors-300x65.jpg\" alt=\"\" width=\"300\" height=\"65\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Errors-300x65.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Errors-768x166.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Errors.jpg 920w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Output.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-4460\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Output-300x170.jpg\" alt=\"\" width=\"300\" height=\"170\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Output-300x170.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Output-768x434.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617UpdatePSModules-Output.jpg 914w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Once the JSON file is written to the Azure File Share you can protect the Azure file share with Azure Backup. Read more about backup for Azure file shares <a href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/introducing-backup-for-azure-file-shares\/\">here<\/a>.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617AzureFileShare.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-4462\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617AzureFileShare-300x87.jpg\" alt=\"\" width=\"300\" height=\"87\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617AzureFileShare-300x87.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617AzureFileShare-768x222.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617AzureFileShare-1024x296.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/06\/20180617AzureFileShare.jpg 1289w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Disclaimer: Cloud is a very fast-moving environment. It means that by the time you\u00e2\u20ac\u2122re reading this post everything described here could have been changed completely. Note that this is provided \u00e2\u20ac\u0153AS-IS\u00e2\u20ac\u009d with no warranties at all. This is not a production ready\u00c2\u00a0solution for your production environment, just an idea, and an example.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Earlier this week I put together a runbook to backup Azure Resource Manager (ARM) templates for existing Resource Groups. The runbook exports the resource group as a template and saves it to a JSON file. The JSON file is then uploaded to an Azure File Share that can be protected with Azure Backup. The runbook &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=4455\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":4456,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[64,70],"tags":[],"class_list":["post-4455","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-runbook"],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4455"}],"version-history":[{"count":2,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4455\/revisions"}],"predecessor-version":[{"id":4464,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4455\/revisions\/4464"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/media\/4456"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4455"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}