Adding APIM Backend for Logic App using PowerShell not working

John F. Kennedy 6 Reputation points
2023-04-20T22:21:16.71+00:00

Hi, I have written a PowerShell script to add a Logic App to APIM. When I create a new Backend for the Logic App using New-AzApiManagementBackend, it appears the Backend is not setup correctly as when I look at it in the Azure UI, I get an error when I click on the Properties Settings link for the Backend. Further, the Azure resource dropdown on that page is blank as is the Runtime URL. The portions of the script relevant to making the Backend are below. Any help would be very much appreciated. Thanks, John param ($MerchantID='0E3E0E3E-19A0-4229-BD0D-3F6950403F69') $WorkFlow = Get-AzLogicApp -ResourceGroupName "NetProProduction" -Name "NetProAI-WebhooksShopify-Base" $NewWorkFlow = New-AzLogicApp -ResourceGroupName "NetProProduction" -Name "NetProAI-WebhooksShopify-$MerchantID" -Location "northcentralus" -State "Enabled" -Definition $Workflow.Definition $ResourceId = "https://managment.azure.com" + $NewWorkFlow.Id $BackendURL = $NewWorkFlow.AccessEndpoint + "/triggers" $AMContext = New-AzApiManagementContext -ResourceGroupName "BaseMerchantWebhooks" -ServiceName "BaseMerchantWH" $NewBackend = New-AzApiManagementBackend -Context $AMContext -Protocol "http" -Url $BackendURL -BackendId "LogicApp_NetProAI-WebhooksShopify_$MerchantID" -Description "NetProAI-WebhooksShopify-$MerchantID" -ResourceId $ResourceId

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,799 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,896 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,140 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 43,996 Reputation points
    2023-04-21T12:30:19.29+00:00

    Hi, I'd be happy to help you out with your question. Sorry for the inconvenience caused. On the basis of the PowerShell script you provided, I think that you're creating a new Logic App and then adding a backend for it in Azure API Management. However, there are a few things that you could check to ensure that the backend is set up correctly. Firstly, please ensure that the $BackendURL variable is pointing to the correct URL for your Logic App. You can test this by opening the URL in a web browser and verifying that it returns the expected response. Secondly, please check that the $ResourceId variable is set correctly and is pointing to the Logic App resource ID. You can verify this by running the following command in PowerShell: Get-AzResource -ResourceId $ResourceId This should return information about the Logic App resource. Finally, please ensure that the API Management service has the necessary permissions to access the Logic App resource. You can grant permissions by going to the Logic App resource in the Azure portal, selecting "Access control (IAM)", and then adding the API Management service as a "Contributor" role. If you've checked these things and the issue persists, it may be helpful to provide the error message or details of what you see in the Azure UI when you click on the Properties Settings link for the backend. If you have any other questions or need assistance with anything, please don't hesitate to let me know. I'm here to help.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

  2. John F. Kennedy 6 Reputation points
    2023-04-21T15:52:33.4066667+00:00

    Thanks for the reply. I continued investigating and comparing to other Backend logic app configurations. The solution was to remove the port from the BackendURL variable when assigning the new logic app's AccessEndpoint URL to it. That solved the issue. $BackendURL = $NewWorkFlow.AccessEndpoint.Replace(":443","") + "/triggers"

    0 comments No comments