API Management backend ARM Template resourceId

Jack Watts 11 Reputation points
2021-03-18T08:05:01.95+00:00

Following the template definition as outlined here: https://learn.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2019-01-01/service/backends?tabs=json#backendcontractproperties-object

Specifically trying to populate the resourceId field:
Management Uri of the Resource in External System. This url can be the Arm Resource Id of Logic Apps, Function Apps or Api Apps.

Should it be called resourceId if it expects a management Uri? Shouldn't it be called managementUri if that is what it expects?

It doesn't appear to accept a resourceId returned by the resourceId function in the arm template.

How do we get the management Uri of the referenced service?

  • try to use reference?: reference(resourceId('Microsoft.Web/sites', parameters('functionAppName')), '2018-02-01').<WhatIsTheManagementUrlPropertyCalled?>)
  • frankenstein the url: [concat('https://management.azure.com/subscriptions/', subscription().tenantId, '/resourceGroups/', ...
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,447 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Frank van Dijk | Brightwave 1 Reputation point
    2021-09-09T13:25:02.683+00:00

    @MayankBargali-MSFT , the documents does not provide information on the format of the resourceId field.
    We're trying to create an ARM template for apimanager including a backend service, https://learn.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2019-01-01/service/backends?tabs=json
    If we add a resource Id (as mentioned on the properties of the logic app), then the error is returned Value should represent absolute http URL

    Where can we find the managementUri of a Logic App?

    130718-image.png

    0 comments No comments

  2. MayankBargali-MSFT 70,936 Reputation points Moderator
    2021-03-18T14:07:54.977+00:00

    Hi @Jack Watts

    Please refer to the below template for HTTP and logic app.

     --For HTTP Function  
     {  
        "type":"Microsoft.ApiManagement/service/backends",  
        "apiVersion":"2020-06-01-preview",  
        "name":"[concat(parameters('your_common_name'), '/{anyname}')]",  
        "dependsOn":[  
           "[resourceId('Microsoft.ApiManagement/service', parameters('your_common_name'))]"  
        ],  
        "properties":{  
           "description":"{yourdescription}",  
           "url":"https://{yourfunctionappname}.azurewebsites.net/api",  
           "protocol":"http", "resourceId":"https://management.azure.com/subscriptions/{yoursubscriptionID}/resourceGroups/{yourresourcegroupname}/providers/Microsoft.Web/sites/{functionappname}",  
           "credentials":{  
              "header":{  
                 "x-functions-key":[  
                    "{  
                     {yourfunctionappkeynamed}}"  
                 ]  
              }  
           }  
        }  
     }  
          
     {  
        "type":"Microsoft.ApiManagement/service/namedValues",  
        "apiVersion":"2020-06-01-preview",  
        "name":"[concat(parameters('your_common_name'), '/{yourfunctionappkeynamed}')]",  
        "dependsOn":[  
           "[resourceId('Microsoft.ApiManagement/service', parameters('your_common_name'))]"  
        ],  
        "properties":{  
           "displayName":"{keyname}",  
           "tags":[  
              "key",  
              "function",  
              "auto"  
           ],  
           "secret":true  
        }  
     }  
     {  
                "type": "Microsoft.ApiManagement/service/properties",  
                "apiVersion": "2019-01-01",  
                "name": "[concat(parameters('your_common_name'), '/{keyname}')]",  
                "dependsOn": [  
                    "[resourceId('Microsoft.ApiManagement/service', parameters('your_common_name'))]"  
                ],  
                "properties": {  
                    "displayName": "{anyname}",  
                    "value": "{yourfunctionFunctionKey}",  
                    "tags": [  
                        "key",  
                        "function",  
                        "auto"  
                    ],  
                    "secret": true  
                }  
            }  
          
     ---For Logic App  
     {  
        "type":"Microsoft.ApiManagement/service/backends",  
        "apiVersion":"2020-06-01-preview",  
        "name":"[concat(parameters('your_common_name'), '/{anyname}')]",  
        "dependsOn":[  
           "[resourceId('Microsoft.ApiManagement/service', parameters('your_common_name'))]"  
        ],  
        "properties":{  
           "description":"{yourdescription}",  
           "url":"{https://prod-25.westus2.logic.azure.com/workflows/84cef96340cd408fa41bsadasb6eb62a4/triggers}----{yourworkflowtriggerurl}",  
           "protocol":"http",  
           "resourceId":"https://management.azure.com/subscriptions/{yoursubscriptionID}/resourceGroups/{yourresourcegroupname}/providers/Microsoft.Logic/workflows/{workflowname}"  
        }  
     }  
    

    Reference:
    https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource?tabs=json#return-value
    https://learn.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2019-01-01/service/backends?tabs=json

    Let me know if you have any queries or concerns.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.