Bootstrap Azure Arm 模板的 DSC 扩展

Bootstrap DSC extension for a Azure Arm template

我有一个 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,计划是使用chocolately 但这也需要先安装才能使用它来安装程序。是否可以 "bootstrap" DSC 执行?

似乎此功能目前不支持作为 scaleset 扩展 运行 并行。可能首选的选择是通过 custom script extension

在 powershell 脚本 运行 中实现 bootstrap

您可以创建几个单独的 powershell 脚本存储在 blobstorage 中并用 && 分隔调用它们 这是一个通过 powershell before 部署 dotnet.core.

将新 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" } }