mslot
mslot

Reputation: 5224

API management ARM template creation

I have this resource defined in my ARM template, with a single API, with a single operation, but when i deploy the template it does not include the API. What am I missing?

   {
      "apiVersion": "2017-03-01",
      "name": "[variables('am-apimanagement-service-name')]",
      "type": "Microsoft.ApiManagement/service",
      "location": "North Europe",
      "tags": {},
      "sku": {
        "name": "[parameters('am-sku')]",
        "capacity": "[parameters('am-skuCount')]"
      },
      "properties": {
        "publisherEmail": "[parameters('am-publisher-email-p')]",
        "publisherName": "[parameters('am-publisher-name-p')]",
        "resources": [
          {
            "type": "Microsoft.ApiManagement/service/apis",
            "apiVersion": "2017-03-01",
            "name": "testapi",
            "dependsOn": [
              "[concat('Microsoft.ApiManagement/service',variables('am-apimanagement-service-name'))]"
            ],
            "properties": {
              "displayName": "TestApi",
              "description": "",
              "serviceUrl": "https://testdevsite.azurewebsites.net",
              "path": "testpath",
              "protocols": [
                "https"
              ],
              "authenticationSettings": null,
              "subscriptionKeyParameterNames": null,
              "isCurrent": true,
              "apiVersion": null,
              "resources": [
                {
                  "apiVersion": "2017-03-01",
                  "type": "operations",
                  "name": "GetOperation",
                  "dependsOn": [
                    "[concat('Microsoft.ApiManagement/service/', variables('am-apimanagement-service-name'), '/apis/testapi')]"
                  ],
                  "properties": {
                    "displayName": "GET",
                    "method": "GET",
                    "urlTemplate": "/resource",
                    "description": "Get"
                  }
                }
              ]
            }
          }
        ]
      }
    }

It creates the API management resource just fine, but it does not include my API.

I must be configuring something wrong, I just cant see it.

Basically what I want is an API that calls a Web API located in same resource group.

Upvotes: 1

Views: 302

Answers (1)

mslot
mslot

Reputation: 5224

The missing part here is that I was unable to wrap my head around the simple fact that the subresources was put under the properties. When this was corrected, everything was fine:

   {
      "apiVersion": "2017-03-01",
      "name": "[variables('am-apimanagement-service-name')]",
      "type": "Microsoft.ApiManagement/service",
      "location": "North Europe",
      "sku": {
        "name": "[parameters('am-sku')]",
        "capacity": "[parameters('am-skuCount')]"
      },
      "properties": {
        "publisherEmail": "[parameters('am-publisher-email-p')]",
        "publisherName": "[parameters('am-publisher-name-p')]"
      },
      "resources": [
        {
          "type": "apis",
          "apiVersion": "2017-03-01",
          "name": "test",
          "dependsOn": [
            "[concat('Microsoft.ApiManagement/service/',variables('am-apimanagement-service-name'))]"
          ],
          "properties": {
            "displayName": "test",
            "description": "",
            "serviceUrl": "[concat('https://test-webapi-',parameters('environment'),'.azurewebsites.net')]",
            "path": "test",
            "protocols": [
              "https"
            ],
            "isCurrent": true
          },
          "resources": [
            {
              "apiVersion": "2017-03-01",
              "type": "operations",
              "name": "Get",
              "dependsOn": [
                "[concat('Microsoft.ApiManagement/service/', variables('am-apimanagement-service-name'), '/apis/test')]"
              ],
              "properties": {
                "displayName": "GET",
                "method": "GET",
                "urlTemplate": "/api/sites",
                "description": "Get"
              }
            }
          ]

        }
      ]
    }

Upvotes: 1

Related Questions