Azure 虚拟机规模集上的自定义数据

问题描述

需要在 azure 虚拟机规模集 (Windows) 中自定义数据来安装 IIS 服务器并替换认的 iis 页面回显服务器的主机名。感谢这方面的任何指导,

解决方法

根据您的要求,我想在您的虚拟机规模集上推荐 Azure 自定义脚本扩展。

Here 是官方示例。这将安装 IIS Web 服务器并输出规模集 VM 实例的主机名。自定义脚本扩展定义从 GitHub 下载示例脚本,安装所需的包,然后将虚拟机实例主机名写入基本 HTML 页面。

$customConfig = @{
  "fileUris" = (,"https://raw.githubusercontent.com/Azure-Samples/compute-automation-configurations/master/automate-iis.ps1");
  "commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File automate-iis.ps1"
}

# Get information about the scale set
$vmss = Get-AzVmss `
          -ResourceGroupName "myResourceGroup" `
          -VMScaleSetName "myScaleSet"

# Add the Custom Script Extension to install IIS and configure basic website
$vmss = Add-AzVmssExtension `
  -VirtualMachineScaleSet $vmss `
  -Name "customScript" `
  -Publisher "Microsoft.Compute" `
  -Type "CustomScriptExtension" `
  -TypeHandlerVersion 1.9 `
  -Setting $customConfig

# Update the scale set and apply the Custom Script Extension to the VM instances
Update-AzVmss `
  -ResourceGroupName "myResourceGroup" `
  -Name "myScaleSet" `
  -VirtualMachineScaleSet $vmss