2

I have tried to retrieve the HTTP trigger URL from my singel-tenant logic app, but without success.

using:

listCallbackUrl(resourceId('resource-group-name','Microsoft.Logic/workflows', 'logic-app-name', 'manual'), '2016-06-01').value

Also tried:

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/listCallbackUrl?api-version=2016-06-01

This does not find the actual workflow.

and

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/functions/{functionName}/listsecrets?api-version=2019-08-01

This request returns an URL which seem to be a function URL but not the actual trigger URL. Any ideas why this doesn't work? Are there any work-arounds?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
K.J.M.O.
  • 145
  • 2
  • 14
  • under the hood, logic app standard runs on top of function app so would make sense that the url looks like a function app url. Can you validate that the trigger url form the azure portal is different from what you get from calling the ARM api – Thomas Sep 01 '21 at 13:16
  • Yes I can validate that. The actual URL i retrieve is: https://mysite.azurewebsites.net/api/myworkflowname?code=cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxA== But it should look like this: https://mysite.azurewebsites.net:443/api/myworkflow/triggers/manual/invoke?api-version=2020-05-01-preview&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx – K.J.M.O. Sep 02 '21 at 08:32
  • so should be good ? when you try to trigger your logic app using this url, is it working ? – Thomas Sep 02 '21 at 08:34
  • Yes when I use the actual trigger URL it works just fine. But I need to be able to retrieve it from my ARM template when deploying. This does not seem to work. – K.J.M.O. Sep 02 '21 at 08:36
  • You can recreate this error here: https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/list-function-secrets – K.J.M.O. Sep 02 '21 at 12:03
  • You can refer to a similar open issue on GitHub at [Not able to retrieve Workflow URL from ARM template](https://github.com/Azure/logicapps/issues/301) and [Getting callback url for logic app in ARM](https://stackoverflow.com/questions/47012601/getting-callback-url-for-logic-app-in-arm). You can open this issue as well here: https://github.com/Azure/logicapps/issues – Ecstasy Sep 06 '21 at 05:15

2 Answers2

2

I solved the problem by adding the following task (in the yaml file) exactly before the task that need to use this link:

          # getUrl
          - task: AzureCLI@2
            displayName: getLAUrl
            name: getLAUrl
            inputs:
              azureSubscription: "${{ parameters.connectedServiceName }}"
              scriptType: ps
              scriptLocation: inlineScript
              inlineScript: |
                $subscription = az account list --query "[?isDefault].id | [0]"
                $ResourceGroupName = "${{ parameters.LA_rg }}"
                $LogicAppName = "${{ parameters.LA_name }}-${{parameters.environment}}"
                $MyWorkflow = "${{ parameters.LA_workflow }}"
                
                $workflowDetails = az rest --method post --uri https://management.azure.com/subscriptions/$subscription/resourceGroups/$ResourceGroupName/providers/Microsoft.Web/sites/$LogicAppName/hostruntime/runtime/webhooks/workflow/api/management/workflows/$MyWorkflow/triggers/manual/listCallbackUrl?api-version=2018-11-01
                # Write-Host "$workflowDetails"

                echo "##vso[task.setvariable variable=WorkFlowDetails2]$workflowDetails"

This task will return a json object that contains the URL of the workflow (with some other stuff and details about this workflow) using cli commands (this cli command is working according to this issue). After getting this json $workflowDetails, I assigen this parameter to a variable called WorkFlowDetails2. WorkFlowDetails can now be accessed in other tasks inside the SAME job (if you want to use it inside other jobs you need to make it as output parameter). After thatyou can use this parameter normally in other task by calling something like: $(WorkFlowDetails)

So for e.g., if I need the workflow url to add it in namedValues in API management, I can have this task:

    - task: AzureResourceManagerTemplateDeployment@3
            displayName: DeployNamedValue
            inputs:
              deploymentScope: "Resource Group"
              ConnectedServiceName: "${{ parameters.connectedServiceName }}"
              action: "Create Or Update Resource Group"
              resourceGroupName: "${{ parameters.resourceGroup }}"
              location: ${{ parameters.location }} 
              templateLocation: "Linked artifact"
              csmFile: '$(Pipeline.Workspace)/allApiArtifact/namedValues-template.json'
              overrideParameters: '-LA_object_details $(WorkFlowDetails2) -LA_name ${{ parameters.LA_name }} -ApimServiceName ${{parameters.ApimServiceName}} -LA_workflow ${{parameters.LA_workflow}}' 
              deploymentMode: "Incremental"  

My named value template now will looks something like:

    {
       "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "ApimServiceName": {
          "type": "string",
          "defaultValue": "test"
        },
        "LA_name": {
          "type": "string",
          "defaultValue": "la_name"
        },
        "LA_workflow": {
          "type": "string",
          "defaultValue": "la_workflow" 
        },
        "LA_object_details": {
          "type": "object",
          "defaultValue": {
            "basePath": "",
            "method": "",
            "queries": {
              "api-version": "",
              "sig": "",
              "sp": "",
              "sv": ""
            },
            "value": ""
          }
        }
      },
      "variables":{
        "la_version": "2020-05-01-preview",
        "namedValue_prefix": "[split(parameters('LA_name'),'-')[0]]",
        "namedValue_name": "[concat(variables('namedValue_prefix'), 'Url')]"
      },
      "resources": [
        {
          "properties": {
            "tags": [],
            "secret": true,
            "displayName": "[variables('namedValue_name')]",
            "value": "[concat('/api/', parameters('LA_workflow'), '/triggers/manual/invoke?api-version=', variables('la_version'), '&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=', parameters('LA_object_details').queries.sig)]"
          },
          "name": "[concat(parameters('ApimServiceName'), '/', variables('namedValue_name'))]",
          "type": "Microsoft.ApiManagement/service/namedValues",
          "apiVersion": "2021-01-01-preview"
        }
    
      ]
    }

ibda
  • 376
  • 3
  • 15
2

To get the callback URL for a standard logic app workflow in ARM template:

[listCallbackUrl(resourceId('Microsoft.Web/sites/hostruntime/webhooks/api/workflows/triggers', parameters('logicAppName'), 'runtime', 'workflow', 'management', parameters('workflowName'), 'manual'),'2021-03-01').value]

To get the callback URL for a consumption logic app in ARM template:

[listCallbackUrl(resourceId('Microsoft.Logic/workflows/triggers', parameters('workflowName'), 'manual'),'2021-03-01').value]

Please check this article for further information:

https://github.com/yasseralissa/standard-logicapp-callbackurl

Yasser
  • 864
  • 1
  • 9
  • 19