【问题标题】:ARM Template with DSC extension: Powershell file location from local destop带有 DSC 扩展的 ARM 模板:来自本地桌面的 Powershell 文件位置
【发布时间】:2017-06-05 11:08:48
【问题描述】:

我想将带有 DSC 相关 PS 脚本的 ARM 模板项目发送给第三方。他们可能会在 VS 中部署选项来进行部署。是否可以将 DSC 脚本作为 ARM 项目的一部分附加并在部署时从本地磁盘获取 dsc 脚本?在设置下,我们有“ModulesUrl”,可以将其替换为另一个指向本地磁盘的参数,例如 c:\myproject\IISInstall.ps1.zip

{
  "apiVersion": "2015-06-15",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', parameters('webSrvVmName'))]"
  ],
  "location": "[resourceGroup().location]",
  "name": "qawebsrv/iisinstall",
  "properties": {
    "publisher": "Microsoft.Powershell",
    "type": "DSC",
    "typeHandlerVersion": "2.19",
    "autoUpgradeMinorVersion": true,
    "settings": {
      "ModulesUrl": "https://dscscript.blob.core.windows.net/dscscripts/IISInstall.ps1.zip",
      "ConfigurationFunction": "[variables('configurationFunction')]",
      "Properties": {},
      "SasToken": "",
      "wmfVersion": "4.0"
    },
    "protectedSettings": {}
  },
  "tags": {
    "displayName": "VM Extensions"
  },
  "type": "Microsoft.Compute/virtualMachines/extensions"
}

【问题讨论】:

    标签: visual-studio azure-resource-manager dsc


    【解决方案1】:

    如果您打算使用 VS 进行部署,那么 VS 可以为您暂存 DSC 包 - VS 中的部署脚本会执行此操作...它实际上也可以构建 DSC 包,但有一些限制。

    VS 脚本没有什么神奇之处 - 这个 repo 有一个 DSC 示例,它使用 VS 使用的相同脚本 - 请参阅:https://github.com/bmoore-msft/AzureRM-Samples/tree/master/VMDSCInstallFile

    对于“Hello World”示例...

    【讨论】:

      【解决方案2】:

      不,这是不可能的。最接近的方法是将脚本上传到公开的地方,VM 会拉取它。

      "properties": {
          "publisher": "Microsoft.Powershell",
          "type": "DSC",
          "typeHandlerVersion": "2.20",
          "autoUpgradeMinorVersion": true,
          "settings": {
              "configuration": {
                  "url": "https://github.com/xxx.zip",
                  "script": "scriptname.ps1",
                  "function": "main"
              },
              "configurationArguments": {}
          },
          "protectedSettings": {}
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多