APIManagementARMTemplateCreator icon indicating copy to clipboard operation
APIManagementARMTemplateCreator copied to clipboard

Named values used in backend definitions

Open mikaelsand opened this issue 2 years ago • 2 comments

DependsOn not set

When defining a backend and use a named value, that named value is extracted in the template. So far so good. But that backend is not set to depend on the same named value, leading to errors in deployment since the backend might be deployed before the named value is. Manually updating the template made it work just fine.

Original template code

(deleted some for readability)

{
      "type": "Microsoft.ApiManagement/service/backends",
      "name": "[concat(parameters('My_API_Service_name'), '/' ,'LogicAppName')]",
      "apiVersion": "2019-01-01",
      "properties": {
        "url": "Long tings pointing to a logic app in this case",
        "resourceId": "Pointing to said logic app",
        "credentials": {
          "query": {
            "sig": [
              "{{MyLogicAppKey}}"
            ]
          },
          "header": {}
        },
      "dependsOn": []
    },
    {
      "type": "Microsoft.ApiManagement/service/namedValues",
      "name": "[concat(parameters('My_API_Service_name'), '/', 'MyLogicAppKey')]",
      "apiVersion": "2020-06-01-preview",
      "properties": {
        "displayName": "MyLogicAppKey",
        "secret": true,
        "value": "A long thing pointing to the signature in the Logic app"
      },
      "resources": [],
      "dependsOn": []
    }

My updated template code

(Just the affected part the post is getting too long)

{
      "type": "Microsoft.ApiManagement/service/backends",
      "name": "[concat(parameters('My_API_Service_name'), '/' ,'LogicAppName')]",
      "apiVersion": "2019-01-01",
      "properties": {
        "url": "Long tings pointing to a logic app in this case",
        "resourceId": "Pointing to said logic app",
        "credentials": {
          "query": {
            "sig": [
              "{{MyLogicAppKey}}"
            ]
          },
          "header": {}
        },
      "dependsOn": [
        "[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('My_API_Service_name'), 'MyLogicAppKey')]"
      ]
    },

mikaelsand avatar Feb 09 '22 14:02 mikaelsand

Hi! Having the same issue. @mikaelsand : did you find any solution for it or just went manual?

@MLogdberg : Something you have been looking into?

e-karlsson avatar Sep 06 '22 13:09 e-karlsson

Sorry. I had to use the manual approach.

mikaelsand avatar Sep 06 '22 14:09 mikaelsand