我正在寻找一种运行脚本的方法,该脚本创建一个带有rdp端口的简单Windows vm并在其上安装软件,以便为我们的客户提供一个用于测试目的的简单沙盒服务器。我已经苦苦挣扎了一段时间,有没有简单的方法可以做到这一点。
答案 0 :(得分:1)
您应将custom script extension用于Azure VM。根据创建虚拟机的方式,可以使用powershell \ cli \ arm模板\ rest api \ sdk来使用该扩展名。
示例powershell:
$ProtectedSettings = @{"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File \\filesvr\build\serverUpdate1.ps1"};
Set-AzureRmVMExtension -ResourceGroupName myRG
-Location myLocation `
-VMName myVM `
-Name "serverUpdate"
-Publisher "Microsoft.Compute" `
-ExtensionType "CustomScriptExtension" `
-TypeHandlerVersion "1.9" `
-ProtectedSettings $ProtectedSettings
ARM模板示例:https://github.com/Azure/azure-quickstart-templates/tree/master/201-vm-custom-script-windows
AZ cli样本:https://blogs.technet.microsoft.com/paulomarques/2017/02/13/executing-custom-script-extension-using-azure-cli-2-0-on-an-azure-linux-virtual-machine/