azure - 在 azure 中创建 vm 并运行安装脚本
问题描述
我正在寻找一种方法来运行一个脚本,该脚本创建一个带有 rdp 端口的简单 windows vm 并在其上安装一个软件,以便为我们的客户提供一个简单的沙盒服务器用于测试目的。有没有一种简单的方法可以做到这一点,因为我已经挣扎了一段时间。
解决方案
您应该为 Azure VM 使用自定义脚本扩展。根据您创建虚拟机的方式,您可以使用 powershell\cli\arm templates\rest api\sdk 来使用该扩展。
示例电源外壳:
$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/
推荐阅读
- docker - 如何确保我的 docker 镜像/容器在 100 年后仍然可以工作?
- arrays - 如何使用 flexbox 和 *ngFor 显示分组数据
- java - Java子串恰好来自同一字符串中每个单词的3个字母
- javascript - 在 beforeUpload 事件上停止上传/处理 ant-design Upload 组件
- c - 在 fscanf 输出的代码前添加编号
- java - OpenTok 和 ARCore
- flutter - 一个 RenderFlex 在底部溢出了 117 个像素。相关的导致错误的小部件是:列
- django - 如何在 Django 管理面板中多次添加字段
- reactjs - 使用 react 获取 post 方法后重定向不起作用
- python - python qt5文本框替换怎么办