Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get Azure Function URL directly by code in Azure Function Apps?

In Azure Portal, you can get function URL directly from portal. there is also another way here that you can get Azure Function URL using Azure ARM API. But I want to know, Is there any way to get "Function URL" by code (Node.js, Python, ...) in Azure Function Apps directly?

enter image description here

like image 390
Reza Amya Avatar asked Aug 13 '18 15:08

Reza Amya


1 Answers

For Node.js azure function, you can just use this line of code: req.originalUrl.

Detailed steps as below:

1.In Azure portal, create a Http Trigger function, select JavaScript as it's Programming Language.

2.In the index.js file, add this line of code: context.log(req.originalUrl);

3.Sample code like below:

  module.exports = function (context, req) {

       context.log(req.originalUrl);
       //write you other logic below
  };

Please refer to the screenshot below for test result: enter image description here

like image 103
Ivan Yang Avatar answered Sep 28 '22 04:09

Ivan Yang