微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用于代理部署到 Windows 操作系统的 Azure 自定义脚本扩展问题

如何解决用于代理部署到 Windows 操作系统的 Azure 自定义脚本扩展问题

我正在使用自定义脚本扩展 (CSE) 在 Windows 虚拟机中设置代理,然后安装防病毒解决方案。防病毒解决方案设置需要互联网连接。但似乎在 CSE 配置期间,代理配置并未立即生效,因此防病毒安装失败。这是我的代理设置脚本:

Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxySettingsPerUser -Value 0
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -Value "123.123.123.123:80"
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -Value 1

netsh winhttp set proxy 123.123.123.123:80

在 CSE 配置之后,当我连接到虚拟机时,我看到代理设置正确并且能够访问互联网。此外,可以通过手动启动脚本来安装防病毒解决方案。我的问题是在 CSE 配置期间代理配置没有立即生效,并且由于没有互联网,杀毒软件失败。

以下是 CSE 部署政策声明的一部分:

"resources": [
  {
    "apiVersion": "2015-06-15","copy": {
      "count": "[length(variables('vmListArray'))]","name": "avAgentcopy"
    },"location": "[parameters('vmLocation')]","name": "[concat(trim(variables('vmListArray')[copyIndex()]),'/AntivirusAgent')]","properties": {
      "autoUpgradeMinorVersion": true,"protectedSettings": {
        "commandToExecute": "[concat ('powershell -ExecutionPolicy Unrestricted -File \"./Scripts/installation-proxy-windows.ps1\" && powershell -ExecutionPolicy Unrestricted -File \"./Scripts/installation-antivirus-windows.ps1\" ')]","storageAccountKey": "mykey","storageAccountName": "mystorageaccount"
      },"publisher": "Microsoft.Compute","settings": {
        "fileUris": "[split(variables('fileUris'),' ')]"
      },"type": "CustomScriptExtension","typeHandlerVersion": "1.7"
    },"type": "Microsoft.Compute/virtualMachines/extensions"
  }
],"variables": {
  "fileUris": "https://mystorageaccount.blob.core.windows.net/mycontainer/Scripts/installation-antivirus-windows.ps1 https://mystorageaccount.blob.core.windows.net/mycontainer/Scripts/installation-proxy-windows.ps1","vmListArray": "[split(parameters('vmList'),',')]"
}  

所以我的问题是为什么自定义脚本扩展代理设置不会立即生效?有没有办法克服这个问题或替代方法

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。