{"id":195,"date":"2025-08-18T15:11:21","date_gmt":"2025-08-18T22:11:21","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/?p=195"},"modified":"2025-08-18T15:11:21","modified_gmt":"2025-08-18T22:11:21","slug":"handling-machine-reboots-with-vm-applications","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/handling-machine-reboots-with-vm-applications\/","title":{"rendered":"Handling Machine Reboots with VM Applications"},"content":{"rendered":"<p>One confusion around all of our extensions is: how are reboots handled? This <a href=\"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/when-will-customscript-extension-re-execute-my-script\/\">varies by extension<\/a>, but only VM Applications provide the option on\u00a0<em>how<\/em> to handle them. It does this via the &#8220;scriptBehaviorAfterReboot&#8221; property.<\/p>\n<div>\n<div>\u00a0\u00a0\u00a0\u00a0&#8220;resources&#8221;:\u00a0[<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;type&#8221;:\u00a0&#8220;Microsoft.Compute\/galleries\/applications\/versions&#8221;,<\/div>\n<div><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;apiVersion&#8221;: &#8220;2024-03-03&#8221;,<\/strong><\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;name&#8221;: &#8220;[concat(parameters(&#8216;galleries_mygallery_name&#8217;), &#8216;\/&#8217;, parameters(&#8216;applicationDefinitionName&#8217;), &#8216;\/&#8217;, parameters(&#8216;version&#8217;))]&#8221;,<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;location&#8221;:\u00a0&#8220;[parameters(&#8216;resourceLocation&#8217;)]&#8221;,<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;properties&#8221;:\u00a0{<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;publishingProfile&#8221;:\u00a0{<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;source&#8221;:\u00a0{<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;mediaLink&#8221;:\u00a0&#8220;[parameters(&#8216;servicePackageLink&#8217;)]&#8221;<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0},<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;manageActions&#8221;:\u00a0{<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;install&#8221;:\u00a0&#8220;[parameters(&#8216;installScript&#8217;)]&#8221;,<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;remove&#8221;:\u00a0&#8220;echo\u00a0\\&#8221;Done\\&#8221;&#8221;<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0},<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;settings&#8221;:\u00a0{<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;packageFileName&#8221;: &#8220;[parameters(&#8216;packageFileName&#8217;)]&#8221;,<\/div>\n<div>\u00a0 \u00a0<strong> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#8220;scriptBehaviorAfterReboot&#8221;:&#8221;Rerun&#8221;<\/strong><\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0},<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;enableHealthCheck&#8221;:\u00a0false,<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;targetRegions&#8221;:\u00a0&#8220;[parameters(&#8216;replicationLocations&#8217;)]&#8221;,<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;replicaCount&#8221;:\u00a03,<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;excludeFromLatest&#8221;:\u00a0false,<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;storageAccountType&#8221;:\u00a0&#8220;Standard_ZRS&#8221;<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0},<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;safetyProfile&#8221;:\u00a0{<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;allowDeletionOfReplicatedLocations&#8221;:\u00a0true<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0]<\/div>\n<\/div>\n<div><\/div>\n<div>Note that, as above, the API version used must be at least 2024-03-03 for this to work.<\/div>\n<div><\/div>\n<div>Valid values are:<\/div>\n<div><\/div>\n<div>\n<table style=\"border-collapse: collapse; width: 17.714%;\">\n<tbody>\n<tr>\n<td style=\"width: 0.777605%;\"><strong>Value<\/strong><\/td>\n<td style=\"width: 0.777605%;\"><strong>Action<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 0.777605%;\">None<\/td>\n<td style=\"width: 0.777605%;\">Take no action after a reboot<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 0.777605%;\">Rerun<\/td>\n<td style=\"width: 0.777605%;\">Run the script again after a reboot<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>There are some things to keep in mind:<\/p>\n<ul>\n<li>This is currently only enabled for ARM templates. CLI and Powershell have not been updated yet.<\/li>\n<li>If the option &#8220;Rerun&#8221; is chosen, then it will apply to\u00a0<em>all<\/em> scripts for the application &#8211; install, update, and remove.<\/li>\n<li>Your scripts must be idempotent if Rerun is chosen. We currently do not inform the script whether a reboot has just occurred.<\/li>\n<li>After three reboots, we will\u00a0<em>not<\/em> execute the script again even if Rerun is specified. This is to prevent a non-idempotent script from continuously rebooting a machine.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One confusion around all of our extensions is: how are reboots handled? This varies by extension, but only VM Applications provide the option on\u00a0how to handle them. It does this via the &#8220;scriptBehaviorAfterReboot&#8221; property. \u00a0\u00a0\u00a0\u00a0&#8220;resources&#8221;:\u00a0[ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;type&#8221;:\u00a0&#8220;Microsoft.Compute\/galleries\/applications\/versions&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;apiVersion&#8221;: &#8220;2024-03-03&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;name&#8221;: &#8220;[concat(parameters(&#8216;galleries_mygallery_name&#8217;), &#8216;\/&#8217;, parameters(&#8216;applicationDefinitionName&#8217;), &#8216;\/&#8217;, parameters(&#8216;version&#8217;))]&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;location&#8221;:\u00a0&#8220;[parameters(&#8216;resourceLocation&#8217;)]&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;properties&#8221;:\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;publishingProfile&#8221;:\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;source&#8221;:\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;mediaLink&#8221;:\u00a0&#8220;[parameters(&#8216;servicePackageLink&#8217;)]&#8221; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;manageActions&#8221;:\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;install&#8221;:\u00a0&#8220;[parameters(&#8216;installScript&#8217;)]&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;remove&#8221;:\u00a0&#8220;echo\u00a0\\&#8221;Done\\&#8221;&#8221; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}, [&hellip;]<\/p>\n","protected":false},"author":103696,"featured_media":197,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[18,4],"class_list":["post-195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vm-applications","tag-reboot","tag-vmapplications"],"acf":[],"blog_post_summary":"<p>One confusion around all of our extensions is: how are reboots handled? This varies by extension, but only VM Applications provide the option on\u00a0how to handle them. It does this via the &#8220;scriptBehaviorAfterReboot&#8221; property. \u00a0\u00a0\u00a0\u00a0&#8220;resources&#8221;:\u00a0[ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;type&#8221;:\u00a0&#8220;Microsoft.Compute\/galleries\/applications\/versions&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;apiVersion&#8221;: &#8220;2024-03-03&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;name&#8221;: &#8220;[concat(parameters(&#8216;galleries_mygallery_name&#8217;), &#8216;\/&#8217;, parameters(&#8216;applicationDefinitionName&#8217;), &#8216;\/&#8217;, parameters(&#8216;version&#8217;))]&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;location&#8221;:\u00a0&#8220;[parameters(&#8216;resourceLocation&#8217;)]&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;properties&#8221;:\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;publishingProfile&#8221;:\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;source&#8221;:\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;mediaLink&#8221;:\u00a0&#8220;[parameters(&#8216;servicePackageLink&#8217;)]&#8221; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;manageActions&#8221;:\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;install&#8221;:\u00a0&#8220;[parameters(&#8216;installScript&#8217;)]&#8221;, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;remove&#8221;:\u00a0&#8220;echo\u00a0\\&#8221;Done\\&#8221;&#8221; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/users\/103696"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/media\/197"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-vm-runtime\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}