Bad Request - Health check to APIM from CD Pipeline

Laramée Emmanuelle (Externe) 5 Reputation points
2024-01-24T19:16:42.7566667+00:00

Hi

I have a CD pipeline in Azure DevOps in which I want to do a health check on my Azure APIM service. I use the action described below

   - task: InvokeRESTAPI@1
		inputs:
			connectionType: 'connectedServiceNameARM'
			azureServiceConnection: '{serviceConnection}'
			method: 'GET'
			urlSuffix: 'https://{baseUrlAPIM}/status-0123456789abcdef?api-version=2022-12-01&subscriptionID={subscriptionID}'
			waitForCompletion: 'false'
			successCriteria: '200'

Pipeline execution fails with this error

400 Bad Request
{
     "error": {
         "code": "BadRequest",
         "message": "Bad request. Diagnostic information: timestamp '20240124T185605Z', subscription id '', tracking id '61364248-3cdb-4605-b2ef-07e52a5a5afb', request correlation id '61364248-3cdb-4605-b2ef-07e52a5a5afbb'. "
     }
}

I don't understand why the query is failing. In the error message, we see that subscription id is empty. When I remove the &subscriptionID={subscriptionID} portion of urlSuffix I get this message

404 Not Found
{
     "error": {
         "code": "MissingSubscription",
         "message": "The request did not have a subscription or a valid tenant level resource provider."
     }
}

When I run the query https://{baseUrlAPIM}/status-0123456789abcdef?api-version=2022-12-01 in Postman I get a 200 Service Operational

What am I missing in the InvokeRESTAPI task configuration?

Thanks

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,784 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 22,156 Reputation points
    2024-01-24T21:27:03.69+00:00

    Laramée Emmanuelle (Externe) Thanks for posting your question in Microsoft Q&A. The default health endpoint of APIM is https://{baseUrlAPIM}/status-0123456789abcdef and there is no need to pass subscription id as a query parameter. You are calling this API correctly (like https://{baseUrlAPIM}/status-0123456789abcdef) and I see that you have validated this via another client like Postman.

    I am not an expert in Azure DevOps and quickly reviewing, the issue appears to be that Azure pipeline task is missing the subscription ID and suggest you validating service connection like described in this discussion. Check out Manage service connections and Connect to Microsoft Azure with an ARM service connection doc and make sure the subscription id is configured in the given scope/connection (and the connection is valid). Troubleshoot ARM service connections may also help in troubleshooting the issue.

    I would like to let you know that Azure DevOps is currently not supported in Microsoft Q&A (supported products in Q&A are listed here). If you have any further questions or issues with pipelines or DevOps, please reach out to https://developercommunity.visualstudio.com/AzureDevOps forum and the community experts will assist you further in resolving the issue.

    I hope this helps and let me know if any questions.


    If you found the answer to your question helpful, please take a moment to mark it as Yes for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.