Is it possible to get azure function URL (at runtime) for Http triggered function app developed in C#.I have implemented a health check for function app.I need to call function URL to check whether the function is healthy or not . I know azure provide services to check FA health but I need to implement as per organization standards. So, Basically it will be a endpoint /healthCheck to get health report.
-
1What are you trying to do here? some code you have so far could be helpful to understand the question.Amr Elgarhy– Amr Elgarhy2021-02-25 10:04:27 +00:00Commented Feb 25, 2021 at 10:04
-
Would you kindly share you code so that we could better visualize your issue.Md Farid Uddin Kiron– Md Farid Uddin Kiron2021-02-25 10:22:06 +00:00Commented Feb 25, 2021 at 10:22
-
I have implemented a health check for function app.I need to call function URL to check whether the function is healthy or not . I know azure provide services to check FA health but I need to implement as per organization standards. So, Basically it will be a endpoint /healthCheck to get health report.suraj_123– suraj_1232021-02-25 10:29:02 +00:00Commented Feb 25, 2021 at 10:29
-
so basically your Function will call itself to do a health check on itself?!silent– silent2021-02-25 13:06:38 +00:00Commented Feb 25, 2021 at 13:06
-
Does the below answer helps your query?Harshita Singh– Harshita Singh2021-03-01 08:24:10 +00:00Commented Mar 1, 2021 at 8:24
2 Answers
While I don't understand yet what you are trying to do (and if that is a good idea..) you can infer your function URL through the pre-set env var WEBSITE_HOSTNAME (assuming you are not using a custom domain):
var url = $"https://{Environment.GetEnvironmentVariable("WEBSITE_HOSTNAME")}/api/YOURFUNCTIONNAME";
Comments
I do not see a need of getting runtime Azure function app URLs as they remain the same always after creation. On the same lines, you can automate your Function Apps using ARM templates.
And, use the created URLs defined in your endpoint's configuration and use them in your code from the configuration. For example, if you are using App Service, you can save those values in App Settings and read them like below:
var value = Environment.GetEnvironmentVariable("your_key_here");