Azure ARM - Microsoft.Resources/deploymentScripts

标签 azure azure-resource-manager azure-powershell azure-automation

我将配置创建的azure VM(例如,安装角色、初始化新硬盘等)。我看到azure ARM中有一个新功能Microsoft.Resources/deploymentScripts。根据文档,我在订阅中创建了托管身份,在订阅上向新创建的托管身份授予贡献者权限等级。然后我使用 Microsoft.Resources/deploymentScripts 功能开发了以下 ARM 模板。代码粘贴在下面。我想将此代码粘贴到我的 ARM 模板中以进行虚拟机部署。问题是我是否能够使用这种方法来执行脚本,例如:在操作系统级别安装角色,如 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"
            }
        }
    ]
}

最佳答案

嗯,是的(有一些技巧),但它并不是为此目的。它用于预配/配置 Azure 级资源,而不是 VM 内部的内容。

您有DSC extensionscript extension为此(适用于 Windows\Linux)。

关于Azure ARM - Microsoft.Resources/deploymentScripts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61077920/

相关文章:

Azure vnet/子网列出连接的设备

azure - 在 Azure 容器实例上运行 Superset

c# - 如何在没有单点登录的情况下使用 Azure AD

azure - 在 Azure DevOps Boards 上如何创建新项目并自动加载模板(而不是选择它)

azure - 如何复制 Azure 资源组

用于获取所提供用户名的订阅列表的 Powershell 脚本

多个环境中的 Azure 云服务项目配置(.csdef 和 .cscfg)

azure - 如何获取单个服务的 Azure 自动化脚本?

azure - 使用 ARM 模板将 Azure Web App 连接到 vNet

azure 管道-根据触发的分支设置变量