I am attempting to add an endpoint to an existing Azure Traffic Manager. When deploying the template below with New-AzureRmResourceGroupDeployment
it erases previous endpoint configurations.
Is it possible to add an endpoint to an existing Traffic Manager through ARM templates without removing the previous ones? Or is the recommendation to use the Azure PowerShell client instead?
{
"$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')]"
}
}
]
}
}
]
}
As an analogy, it is possible to incrementally add access policies to Azure Key Vault like so:
{
"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"
]
}
}
]
}
}
Import ARM Template to Resource Group To bring up the interface for deploying an ARM Template within the Azure Portal, just select “New” in the menu on the left side of the Portal, then search for “Template Deployment” within the Marketplace. Once found, select and create a new “Template Deployment.”
Yes, you can.
The trick is to understand that Traffic Manager endpoints are simultaneously both properties of the profile, but also child resources in their own right.
Your template can therefore deploy an endpoint as a child resource. This will not affect other endpoints or any other profile properties.
For an example, take a look at the Azure Traffic Manager / Web Apps sample in the template gallery.Traffic Manager template.
That sample uses a CopyIndex loop to deploy multiple endpoints incrementally, one for each Web App. You can simplify this, removing the loop, to incrementally add a single endpoint.
It is posible, but due to the fact that the configuration is declarative you need to specify all the existing endpoints and add a new one to those, else they will get deleted like you observe.
anything not specified in the template will get removed ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With