【问题标题】:Bootstrap DSC extension for a Azure Arm templateAzure Arm 模板的引导 DSC 扩展
【发布时间】:2017-10-06 11:17:29
【问题描述】:

我有一个 ARM 模板,它执行 Desired State Configuration 扩展以安装和配置 IIS。但是我需要安装和配置一些需要我已经安装其他工具的区域。

手臂模板

{
        "name": "Microsoft.Powershell.DSC",
        "properties": {
            "publisher": "Microsoft.Powershell",
            "type": "DSC",
            "typeHandlerVersion": "2.20",
            "autoUpgradeMinorVersion": true,
            "forceUpdateTag":"v.4.2",                                   
            "settings": {                                       
                "wmfVersion": "latest",
                "configuration": {
                    "url": "[concat(variables('dscArtifactsLocation'), '/', variables('dscExtensionArchiveFolder'),'/IISInstall.ps1.zip')]",
                    "script": "IISInstall.ps1",
                    "function": "IISInstall"
                },
                "configurationArguments": {
                    "nodeName": "localhost"
                }
            },
            "protectedSettings": {
                "configurationUrlSasToken": "?TOKEN"
            }
        }
    }

IISInstall.ps1

   Node $nodeName
    { 
        WindowsFeature IIS 
        { 
            Ensure = "Present" 
            Name = "Web-Server"                       
        } 

        WindowsFeature AspNet45
        {
            Ensure = "Present"
            Name= "Web-Asp-Net45"
        }
    }

例如,我希望能够使用xWebAdministration,但这需要我先安装它才能打电话

Import-DscResource -ModuleName xWebAdministration

另外我需要安装IISUrlRewrite v2,计划是使用巧克力,但这也需要安装才能使用它来安装程序。是否可以“引导” DSC 执行?

【问题讨论】:

    标签: powershell azure dsc


    【解决方案1】:

    目前似乎不支持此功能,因为scaleset 扩展是并行运行的。可能首选的选项是在通过 custom script extension 运行的 powershell 脚本中实现引导程序

    您可以创建多个存储在 blobstorage 中的单独的 powershell 脚本,并使用 && 分隔调用它们 这是一个通过 powershell before 部署 dotnet.core 向 scaleset 实例添加新 HDD 的示例。

    { "name": "[concat(variables('vmNodeTypeAppName'),'_InitializeVM')]", "properties": { "publisher": "Microsoft.Compute", "settings": { "fileUris": ["https://dot.net/v1/dotnet-install.ps1"] }, "typeHandlerVersion": "1.8", "autoUpgradeMinorVersion": true, "protectedSettings": { "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -Command \"Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -DriveLetter F -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel DataDisk -Confirm:$false\" && powershell.exe -ExecutionPolicy Unrestricted -File dotnet-install.ps1 -SharedRuntime" }, "type": "CustomScriptExtension" } }

    【讨论】:

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