skip to Main Content

I am trying to deploy Traffic manager profile using ARM template but when deploying I am getting the following error . I am referring the resourceid to "resourceTargetId". Also when I create the traffic manager profile from the portal it just seems to work with both deployed apps and no shows no errors.

ERROR

The 'resourceTargetId' property of endpoint 'Primarysite' is invalid or missing. The property must be specified only for the following endpoint types: AzureEndpoints, NestedEndpoints. You must have read access to the resource to which it refers.

ARM template


    {
       "$schema":"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
       "contentVersion":"1.0.0.0",
       "parameters":{
          "DnsName":{
             "type":"string"
          },
          "Name":{
             "type":"String"
          },
          "RoutingMethod":{
             "type":"String"
          },
          "Location":{
             "type":"String"
          }
       },
       "resources":[
          {
             "type":"Microsoft.Network/trafficmanagerprofiles",
             "apiVersion":"2018-08-01",
             "name":"[parameters('Name')]",
             "location":"[parameters('Location')]",
             "properties":{
                "profileStatus":"Enabled",
                "trafficRoutingMethod":"[parameters('RoutingMethod')]",
                "dnsConfig":{
                   "relativeName":"[parameters('DnsName')]",
                   "ttl":30
                },
                "monitorConfig":{
                   "protocol":"HTTPS",
                   "port":443,
                   "path":"/",
                   "expectedStatusCodeRanges":[
                      {
                         "min":200,
                         "max":202
                      },
                      {
                         "min":301,
                         "max":302
                      }
                   ]
                },
                "endpoints":[
                   {
                      "type":"Microsoft.Network/TrafficManagerProfiles/AzureEndpoints",
                      "name":"Primarysite",
                      "properties":{
                         "target":"https://website1.azurewebsites.net",
                         "resourceTargetId":"/subscriptions/xxxxxxxxx-xxxxx-xxxxx-xxxx-xxxxxxxxxxxxxxxx/resourceGroups/RGTest/providers/Microsoft.Web/sites/website1",
                         "endpointStatus":"Enabled",
                         "endpointLocation":"eastus"
                      }
                   },
                   {
                      "type":"Microsoft.Network/TrafficManagerProfiles/AzureEndpoints",
                      "name":"Secondarysite",
                      "properties":{
                         "target":"https://website2.azurewebsites.net",
                         "resourceTargetId":"/subscriptions/xxxxxxxxx-xxxxx-xxxxx-xxxx-xxxxxxxxxxxxxxxxx/resourceGroups/RGTest/providers/Microsoft.Web/sites/website2",
                         "endpointStatus":"Enabled",
                         "endpointLocation":"westus"
                      }
                   }
                ]
             }
          }
       ]
    }

2

Answers


  1. I am not sure from where you got the ARM template that is mentioned in the question. But the issue is with the name of EndpointProperties attribute in your ARM template. The attribute name should be "targetResourceId" and not "resourceTargetId".

    Following are the list of supported attribute names in EndpointProperties:

    • customHeaders
    • endpointLocation
    • endpointMonitorStatus
    • endpointStatus
    • geoMapping
    • minChildEndpoints
    • minChildEndpointsIPv4
    • minChildEndpointsIPv6
    • priority
    • subnets
    • target
    • targetResourceId
    • weight

    More info about the attributes is available in the following EndpointProperties link.

    You can also find a sample traffic manager ARM template in the following official azure quickstart templates link.

    Login or Signup to reply.
  2. I have tried to reproduce the above one by following below steps and ,I have modified a bit in the given code

    1. Create a .json file in vs code
    2. Use the below code
    {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "DnsName": {
          "type": "string"
        },
        "Name": {
          "type": "String"
        },
        "RoutingMethod": {
          "type": "String"
        },
        "Location": {
          "type": "String"
        }
      },
      "resources": [
        {
          "type": "Microsoft.Network/trafficmanagerprofiles",
          "apiVersion": "2018-08-01",
          "name": "[parameters('Name')]",
          "location": "[parameters('Location')]",
          "properties": {
            "profileStatus": "Enabled",
            "trafficRoutingMethod": "[parameters('RoutingMethod')]",
            "dnsConfig": {
              "relativeName": "[parameters('DnsName')]",
              "ttl": 30
            },
            "monitorConfig": {
              "protocol": "HTTPS",
              "port": 443,
              "path": "/",
              "expectedStatusCodeRanges": [
                {
                  "min": 200,
                  "max": 202
                },
                {
                  "min": 301,
                  "max": 302
                }
              ]
            },
            "endpoints": [
              {
                "type": "Microsoft.Network/TrafficManagerProfiles/AzureEndpoints",
                "name": "Primarysite",
                "properties": {
                  "target": "URL of the app which you want to add ",
                  "targetResourceId": "ResourceID of the app which you have provide the URL",
                  "endpointStatus": "Enabled",
                  "endpointLocation": "exact location of the app service "
                }
              },
              {
                "type": "Microsoft.Network/TrafficManagerProfiles/AzureEndpoints",
                "name": "Secondarysite",
                "properties": {
                  "target": "URL of the app which you want to add",
                  "targetResourceId": "ResourceID of the app which you have provide the URL",
                  "endpointStatus": "Enabled",
                  "endpointLocation": "exact location of the app service"
                }
              }
            ]
          }
        }
      ]
    }
    
    1. create a parameter.json in the same folder and use the below code
    {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "DnsName": {
          "value": "zapper0108"
        },
        "Name": {
          "value": "trafficmanager"
        },
        "RoutingMethod": {
          "value": "Performance"
        },
        "Location": {
          "value": "global"
        }
      }
    }
    
    1. Run the code using PowerShell using the below command
    New-AzResourceGroupDeployment -ResourceGroupName "ResourceGroupName" -TemplateFile "FileName.json" -TemplateParameterFile "parameter.json"
    
    1. After the execution you will get below one as output

    enter image description here

    1. After deploying once check in the azure portal you will see below one

    enter image description here

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search