Call Azure Function with ServiceBusTrigger via HTTP throws InvalidOperationException - azure

In our deployed environment, we will have an Azure Function that is triggered via ServiceBus, which is great. But for local testing, I want to be able to make use of the following advice from the following article:
For all kinds of functions other than HTTP triggers and webhooks, you can test your functions locally by calling an administration endpoint. Calling this endpoint with an HTTP POST request on the local server triggers the function. You can optionally pass test data to the execution in the body of the POST request. This functionality is similar to the Test tab in the Azure portal.
However, when I do said post request to localhost:7071/admin/functions/NameOfMyFunction, the following exception gets thrown from within the Azure code:
System.InvalidOperationException: 'No authentication handler is configured to authenticate for the scheme: ArmToken'
For functions with ServiceBusTrigger on them, is there some Authentication header that I need to put on this test HTTP post?

For functions with ServiceBusTrigger on them, is there some Authentication header that I need to put on this test HTTP post?
It odd that you get that error. Based on my test, there is no need to add authentication header for it. I test it with VS 2017,it works correctly on my side.
The following is my detail steps, you could refer to:
1.Create an azure function app and add service bus trigger.
2.Test it with postman
post localhost:7071/admin/functions/{functionName}
body
{"input":"Service Bus Message"}
Console output:

Related

The Webhook receives a bad request from Azure Logic App even though the logic app has not returned any response

I have configured an Azure Logic App with an HTTP trigger and added a few actions with respect to my requirements. In the If condition false block, I used the terminate action to stop the current run for a workflow instance.
I configured the above Azure Logic App endpoint as a webhook. But sometimes the webhook receives a bad request from Azure Logic App. But in the Azure Logic App I didn’t return any response.
Can anyone suggest me Is the issue with 'Terminate' Action or not?
Can anyone suggest me Is the issue with 'Terminate' Action or not?
No, it is not with the Terminate action rather it is with the HTTP Connector that you are using.
After reproducing from my end, I have observed that the below bad request is due to
502 status code which in general is caused when the server did not receive a response.
Since you are using a HTTP Webhook connector, the flow just loops every time the condition is true, and it never ends unless the logic app receives a response in that flow. One way to resolve this is to use a HTTP connector instead of HTTP Webhook since it doesn't require a response to complete the flow rather it just calls the URL.

Does/Should Azure Function authorisation apply when the function is called by a logic app in the same Subscription?

I have an Azure Function with a HTTP trigger and have set the authorisation level on the function to AuthorizationLevel.Function. When calling the function from something like Postman I have to supply the function-key as I expect and I receive a 200 code when it executes (otherwise i get a 401: Unauthorised Access).
However when calling the Function via a Logic App within the same subscription (using the Azure Functions action), the Logic App and Function executes successfully without the need for a function Key.
I would expect the Function to still request the function key from the Logic App, unless this does not apply to resources within the same subscription?
Logic App Build:
Logic App Execution:
It is expected. The built-in Azure Function action uses the complete URL of Http trigger hence we don't need to worry about the authentication. It's all by design because once we are able to find the Azure Functions in the logic app(which locates in the same subscription), which means we have access to them.
If you want to provide authentication key by yourself, you could use Http action instead.

Calling Azure CDN Purge's REST API from Flow returns Unauthorized

I want to purge an Azure CDN endpoint from Microsoft Flow. The CDN Profile's Pricing Ties is Standard Verzion.
I have created a Microsoft Flow with an HTTP - HTTP action.
I used an URL generated by the tool shown by clicking on Try it on https://learn.microsoft.com/en-us/rest/api/cdn/endpoints/purgecontent and filling the necessary fields.
I want to purge all CDN content so I put the following as a body (I hope this is the right way as the official docs were silent about this use case).
{
"contentPaths": [
"/*"
]
}
I have created a Registered application in the Azure Active Directory and used that to fill in Active Directory OAuth fields of the HTTP - HTTP action. I presume that the OAuth authentication is succeeding as if I put wrong values in any of the fields I get a respective error message.
So the HTTP - HTTP action is filled as on the following image. The image mostly shows where I got the values I used on the real flow.
When I run the flow it fails and shows just Unauthorized. inside the failed HTTP - HTTP action.
I have tried to add the app as a Contributor role of the CDN Profile but the error stayed the same.
How to get it working?
According to the error message, it seems that you missed the access token in the request.
If you want to generate the token for your azure ad app(service principal), you could refer to this article and the thread of generating the access token via postman.
Also, you could try to add the app as a role in the logic app.

Azure Bot service talking to Azure Logic App - 401 unauthorized

I have an Azure bot which is all developed and working fine. It currently talks to a 3rd party workflow application via a simple webhook.
I am now trying to replicate this using Azure Logic App. I have a simple logic app that responds fine to requests from POSTMAN. However, when I set the Messaging Endpoint in the Azure Bot service to the URL of the logic app's top node (when a http request is received), I see 401 unauthorized responses from all of my channels in the bot and I don't know why. POSTMAN is using the exact same target URL and works fine.
Any ideas what is going on here?
I had a similar problem, and found the solution was to first ensure an Authorization header is being sent, and 2nd, set the value to null.
Refer: https://learn.microsoft.com/en-us/outlook/actionable-messages/security-requirements#action-authorization-header

Azure Logic Apps - HTTP Listener

I am working on Logic apps with HTTP Listener and tried with the below option rather creating API Controller. Referring below URLs
https://azure.microsoft.com/en-us/documentation/articles/app-service-logic-http-endpoint/
I created a Logic App with "HTTP Request" and do the processing and send the response back to caller. It is working as expected.
but one thing i just wanted to know is , when i create HTTP Request, it provides default URL like below,
https://prod-****.logic.azure.com:443/workflows/*******69a5b764/triggers/request/run?api-version=2015-08-01-preview&sp=%2Ftriggers%2Frequest%2Frun&sv=1.0&sig=*****2MCOoTKZU
Shall we define Custom URL instead default one, like below
Please advise.
There are two different approaches you can hide the original Logic App URL:
Using Azure API Management (APIM)
Using Azure Functions Proxy (AFP)
Through APIM or AFP, you can hide the SAS token part of querystring, sp, sv andd sig, as well as the api-version parameter. Those parameters can be passed through the request header.
By doing so, you can use your own custom URL and hide the SAS token. I've written a blog post about this: https://blog.mexia.com.au/securing-sas-token-from-azure-logic-apps

Resources