Home > database >  How does the Azure function URL is generated?
How does the Azure function URL is generated?

Time:11-12

Currently I have an Azure function in my development environment with the following URL:

https://http-trigger-api-test.azurewebsites.net/api/TestHttpTriggerApi?code=AvAaWlH4Tw8kOXdQRuAqr8euweAf9/OUUc/cSdw9fq7uaAPZ8uj0bB==

This function URL can be divided in 3 parts: http://<yourapp>.azurewebsites.net/api/<funcname>?code=<functionkey>

  1. <yourapp>is the function app URL
  2. funcname is the name of the function written in NodeJS, C#, Python, etc.
  3. <functionkey> how is this code generated?

I am interested to know how the code from part 3 is generated and I am also curious to know if there is a way I can customize this code, i.e., code=device01receive.

Any idea or comment is welcome :)

CodePudding user response:

There are some authorization levels to Azure Functions like User, Function, Admin, Anonymous and System. To restrict the users authorization to our functions, some access keys can be generated by the azure.

We get unauthorized when suitable keys are not passed to the function app URL. Based on the authLevel, we have to pass the keys in the URL.

Anonymous - no authentication is required. Any valid HTTP request passes Function - host (master) and function keys. Admin - requires a host key for authorization. System - requires the master key of a function app for authorization. User - requires a valid authentication token.

Function, Admin & System authorization level are key based.

For more information on authorization level usage in function app, refer here.

I am also curious to know if there is a way I can customize this code, i.e., code=device01receive.

Go to Azure Portal > Your Function App > Functions (in the left index pane) > Select your published function app > click on function keys enter image description here

From here, you can add your customized key to the specific function app. I have created the key provided by you to my function and tested it. Output: enter image description here

  • Related