I have a function app hosted on azure when I get the url endpoint of the function it says https://my_function_app.azurewebsites.net/api/{*segments} instead of https://my_function_app.azurewebsites.net/api/function_name. How do I fix this?
Looks like you have set route template.
If you create function on portal, click Integrate blade and delete values in Route template.
If you deploy pre-complied function to Azure, you should remove this setting in your code.
For c#, set Route=null in HttpTrigger attribute in your .cs file. For js, remove route parameter in function.json file.
Related
earlier we were using azure function app (lets name it func-dev-01 ) for making http function with HTTP trigger which create url as
**https://{function_name_dev}.azurewebsites.net/api/{name}?code=12345678910 ,
**
but for some reason now we are migrating to new azure function app (lets name it fun-prod-01) which create url
** https://{function_name_prod}.azurewebsites.net/api/{name}?code=11121314151617
**
Note: name of both azure function and code are different which is making 2 url's different
How to get same url as old azure function using new azure function ?
You can't. The DNS is provided / handled by AZURE. For such reasons, you should use custom domain and map the way you want:
e.g.
https://mycustomdomain.com (prod)
https://dev.mycustomdomain.com (dev)
Is it possible to lookup the application name for an Azure app as it runs, i.e., get the information about that is displayed in the Azure portal? In the example below, I'd want something to tell me from within the application that I am running sitemap-prod-eastus.
I've been looking at the Azure Context object but not seeing what I need. There is an invocation ID, a name for the function, a directory - not the info in this window.
Maybe this can be done through Azure Application Insights?
I am working in Node JS.
I've not seen anything that would expose this to a function app. That said, there is one sort of workaround that you could do which would work - go to the Configuration blade for the function app, Application settings tab, and add a configuration key like function_name and set its value to the name of your app. Your app could then just read it out of configuration.
It's an extra step, but if you're doing it with something like ARM or Terraform, it's just another configuration entry with a variable you already declared to set up the app in the first place.
Answering my own question: Azure provides WEBSITE_SITE_NAME in the runtime environment that matches the name of the function app.
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?
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:
I'm trying to set up an Azure Function that I want to trigger when a message is put on a Service Bus queue. However, I can´t get it to work. The first "log.Info" does not trigger.
I deployed an Http trigger together with my Service Bus trigger and that works.
Some screenshots is shown below. I´ve already tried to remove the json string with key "generatedBy", as I saw as a suggestion on Google.
There are two files in my Visual Studio project which I have not edited: host.json and local.settings.json, I can´t find information about how to set them up or if it´s necessary at all.
Can anyone help me?
The Connection property of ServiceBusTrigger attribute should refer to a setting name, e.g. ServiceBusConnectionString.
Then, you should put the setting with same name to local.settings.json for local development and to Application settings for Azure.
I needed to append this bit to my ServiceBusConnectionString when running locally:
;TransportType=AmqpWebSockets
Is there a way to map an entire subdomain to an Azure Function and pass in the folder structure without proxying it through a VM or App Service? For instance, https://example.com/path/to/name would pass into an Azure Function something like "path/to/name"?
I was able to resolve this with the help of https://learn.microsoft.com/en-us/azure/azure-functions/functions-proxies.
After creating a new Function App with an Azure Function using JavaScript with an HTTP Trigger, create a Functions Proxy with a route template of {*path} and a Backend URL of https://localhost/api/<trigger name>?code=<trigger code>&path={path}. On a GET, the path is available at req.query.path, and the original url is available at req.originalUrl.