每次重启虚拟机时,是否在 ARM 模板 运行 中指定自定义脚本扩展?

Do custom script extensions specified in ARM templates run each time the VM is restarted?

我使用下面link中的示例模板创建了一个带有自定义脚本扩展的虚拟机:

https://github.com/Azure/azure-quickstart-templates/tree/master/201-vm-custom-script-windows

如果我从 Azure 门户停止并启动 VM,则自定义脚本扩展 运行s 会在启动时出现。但是,如果我从 VM 内部重新启动 VM(通过从“开始”菜单中选择“重新启动”),自定义脚本扩展不会 运行。当从 VM 中重新启动 VM 时,为什么自定义脚本扩展 运行 没有?自定义脚本扩展是否仅在 VM 从释放状态启动时执行?

使用 VM 规模集时,如果我从 Azure 门户解除分配然后启动规模集中的单个 VM,则该 VM 的自定义脚本扩展不会执行。但是,如果我从 Azure 门户取消分配然后启动整个规模集,自定义脚本扩展会为每个 VM 执行。

Azure 自定义脚本扩展允许 Azure VM 的所有者将 运行 脚本存储在 Azure 存储 during or after VM provisioning. The script extension only executes once per VM, not every time the machine boots up - but if you stop the VM via Azure portal, and start the VM again, the VM will be re-provisioned, so the script will run again. Difference between the states of Azure Virtual machines stopped and stopped(deallocated), refer to the link
如果您需要重复 运行 脚本,您可以在自定义脚本扩展中添加时间戳参数,更多信息请参阅 link.

没有。一旦 VM 停止(解除分配或重新启动)然后启动 VM,自定义脚本不会每次都 运行。

自定义脚本将仅即时执行 - 运行仅在 VM 配置期间首次执行。

解除分配 VM 和启动 VM 只与 public ip 地址的变化有关。但是,dns 命名将保持不变。