Change HomePage Azure Function .NET : Your Functions 4.0 app is up and running
chuongmep

chuongmep @chuongmep

About: Computational Design Researcher

Location:
Singapore
Joined:
Aug 1, 2020

Change HomePage Azure Function .NET : Your Functions 4.0 app is up and running

Publish Date: Apr 3
0 0

I have some panic when I search from the internet to see how can we change the home page of Azure Function under .NET. In this post I will help you easy to change it some config and setting .

Image description

You can change it by modifying the content using the host.json.
You need to add "extensions": { "http": { "routePrefix": "" } } in your host.json, Example :

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            },
            "enableLiveMetricsFilters": true
        }
    },
    "extensions": { "http": { "routePrefix": "" } }
}
Enter fullscreen mode Exit fullscreen mode

And now, you need to define a function return the home page information, in this example we will return the home page with result Hello from Azure Function!

[Function("RootFunction")]
        public IActionResult Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get",
                Route = "{ignored:maxlength(0)?}")]
            HttpRequest req,
            string ignored = "")
        {
            _logger.LogInformation($"C# HTTP trigger function processed a request.");
            return new OkObjectResult("Hello from Azure Function!");
        }
Enter fullscreen mode Exit fullscreen mode

Now when you look back after deployment, you can see the result.

Image description

Enjoy !

Reference

Comments 0 total

    Add comment