我正在尝试将终结点添加到现有的Azure Traffic Manager。当使用New-AzureRmResourceGroupDeployment部署以下模板时,它将删除以前的端点配置。

是否可以通过ARM模板将端点添加到现有的Traffic Manager,而无需删除以前的端点?还是建议改用Azure PowerShell客户端?

{
    "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "trafficManagerName": {
            "type": "String"
        },
        "webAppName": {
            "type": "String"
        },
        "webAppLocationRegion": {
            "type": "String"
        },
        "monitorPath": {
            "type": "String"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Network/trafficManagerProfiles",
            "name": "[parameters('trafficManagerName')]",
            "apiVersion": "2017-05-01",
            "location": "global",
            "properties": {
                "profileStatus": "Enabled",
                "trafficRoutingMethod": "Performance",
                "dnsConfig": {
                    "relativeName": "[parameters('trafficManagerName')]",
                    "ttl": 70
                },
                "monitorConfig": {
                    "protocol": "HTTPS",
                    "port": 443,
                    "path": "[parameters('monitorPath')]"
                },
                "endpoints": [
                    {
                        "name": "[parameters('webAppName')]",
                        "type": "Microsoft.Network/trafficManagerProfiles/azureEndpoints",
                        "properties": {
                            "endpointStatus": "Enabled",
                            "targetResourceId": "[resourceId('Microsoft.Web/sites', parameters('webAppName'))]",
                            "weight": 1,
                            "priority": 1,
                            "endpointLocation": "[parameters('webAppLocationRegion')]"
                        }
                    }
                ]
            }
        }
    ]
}

以此类推,可以将访问策略增量添加到Azure Key Vault,如下所示:
{
  "type": "Microsoft.KeyVault/vaults/accessPolicies",
  "name": "[concat(parameters('keyVaultSettings').name, '/add')]", <!-- notice the "/add" -->
  "apiVersion": "2015-06-01",
  "properties": {
      "mode": "Incremental",
      "accessPolicies": [
        {
          "tenantId": "[reference(concat(resourceId('Microsoft.Web/sites', parameters('webAppName')),'/providers/Microsoft.ManagedIdentity/Identities/default'), '2015-08-31-PREVIEW').tenantId]",
          "objectId": "[reference(concat(resourceId('Microsoft.Web/sites', parameters('webAppName')),'/providers/Microsoft.ManagedIdentity/Identities/default'), '2015-08-31-PREVIEW').principalId]",
          "permissions": {
            "secrets": [
              "get",
              "list"
            ]
          }
        }
    ]
  }
}

最佳答案

是的你可以。

诀窍是要了解Traffic Manager端点同时既是配置文件的属性,又是其本身的子资源。

因此,您的模板可以将端点部署为子资源。这不会影响其他端点或任何其他配置文件属性。

例如,查看模板库中的Azure Traffic Manager/Web Apps示例。 Traffic Manager template

该示例使用CopyIndex循环来增量部署多个终结点,每个Web应用程序一个。您可以简化此过程,删除循环,以增量方式添加单个端点。

10-08 09:05