Azure ARM - 微软。Resources/deploymentScripts

Azure ARM - Microsoft.Resources/deploymentScripts

我要配置已创建的 Azure VM(例如,安装角色、初始化新硬盘等)。我看到 azure ARM 中有一个新功能 Microsoft.Resources/deploymentScripts。根据我在订阅中创建的 Managed Identity 的文档,为新创建的 Managed Identity 授予 Contributor 权限, 订阅 级别。然后我使用 Microsoft.Resources/deploymentScripts 功能开发了 ARM 模板。代码粘贴在下面。我想将这段代码粘贴到我的 VM deployment.Question ARM 模板中,如果我能够使用这种方法来执行脚本,例如:在 OS 级别安装角色,如 IIS 或 WSUS,配置 HDD等...

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "type": "string",
            "defaultValue": "'John Dole'"
        },
        "utcValue": {
            "type": "string",
            "defaultValue": "[utcNow()]"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Resources/deploymentScripts",
            "apiVersion": "2019-10-01-preview",
            "name": "runPowerShellInlineWithOutput",
            "location": "westeurope",
            "kind": "AzurePowerShell",
            "identity": {
                "type": "userAssigned",
                "userAssignedIdentities": {
                    "/subscriptions/SubID/resourceGroups/RGname/providers/Microsoft.ManagedIdentity/userAssignedIdentities/MI-ARMdeployment": {}
                }
            },
            "properties": {
                "forceUpdateTag": "[parameters('utcValue')]",
                "azPowerShellVersion": "3.0",
                "scriptContent": "
        $output = 'hello'
         Write-Output $output",
       "arguments": "",
                "timeout": "PT1H",
                "cleanupPreference": "OnSuccess",
                "retentionInterval": "P1D"
            }
        }
    ]
}

嗯,是的(有一些小窍门),但这并不意味着。它适用于 provisioning\configuring Azure 级资源,而不是 VM 内部的东西。

你有 DSC extension and script extension 个(两者都可用 windows\linux)。