{"id":4443,"date":"2018-03-07T10:42:50","date_gmt":"2018-03-07T09:42:50","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=4443"},"modified":"2018-04-17T09:33:55","modified_gmt":"2018-04-17T07:33:55","slug":"argument-is-null-or-empty-error-when-running-post-steps-script-in-azure-site-recovery","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=4443","title":{"rendered":"\u00e2\u20ac\u0153Argument is null or empty\u00e2\u20ac\u009d error when running post-steps script in Azure Site Recovery"},"content":{"rendered":"<p>A couple of days ago I was working on Azure Site Recovery post-step scripts with my colleague\u00c2\u00a0<a href=\"http:\/\/www.systemcenterme.com\/\">Jonathan<\/a>. The scenario was to fail over two virtual machines running in the West Europe Azure region to the North Europe Azure region. Enable replication between two Azure regions is <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/site-recovery\/azure-to-azure-quickstart\">not complicated<\/a>, but not all components are supported to fail over between regions, for example, public IP addresses are not. To get all details about supported scenarios see the Azure Site Replication support matrix <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/site-recovery\/azure-to-azure-support-matrix\">here<\/a>. To set up network after failover we wrote an Azure Automation runbook and connected the runbook to our failover plan as a post-steps script. After Azure Site Recovery has run all fail failover steps it triggers the post-steps scripts.\u00c2\u00a0But we ran into some strange errors in our post step scripts and would like to share the solution with the community.<\/p>\n<p>When doing test failover everything looked ok from the Azure Site Recovery perspective. Our two virtual machines failed over and the first script was triggered. The script will add public IP addresses to the two machines.\u00c2\u00a0<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script004.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4444\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script004-300x292.jpg\" alt=\"\" width=\"300\" height=\"292\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script004-300x292.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script004.jpg 758w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>But when looking in Azure Automation on the runbook job we could see that something was not working.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script001.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4446\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script001-300x141.jpg\" alt=\"\" width=\"300\" height=\"141\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script001-300x141.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script001-768x360.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script001-1024x480.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script001.jpg 1293w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script003.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4445\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script003-300x88.jpg\" alt=\"\" width=\"300\" height=\"88\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script003-300x88.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script003.jpg 762w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script002.jpg\"><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4447\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script002-300x100.jpg\" alt=\"\" width=\"300\" height=\"100\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script002-300x100.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2018\/03\/ASR_Script002.jpg 760w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The runbook could not find the new virtual machine resources in the pre-created resource group. After a couple of different tests, we realized that the new Azure virtual machine resources in North Europe were not ready when the runbook was triggered by the recovery plan.<\/p>\n<p>If we added a small delay on a couple of minutes in the script everything worked perfectly\u00c2\u00a0\ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of days ago I was working on Azure Site Recovery post-step scripts with my colleague\u00c2\u00a0Jonathan. The scenario was to fail over two virtual machines running in the West Europe Azure region to the North Europe Azure region. Enable replication between two Azure regions is not complicated, but not all components are supported to &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=4443\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":4444,"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},"categories":[64],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4443"}],"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=4443"}],"version-history":[{"count":5,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4443\/revisions"}],"predecessor-version":[{"id":4453,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4443\/revisions\/4453"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/media\/4444"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4443"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}