Az Function App PowerShell

Using PowerShell with Azure Functions – Part 1

Off late, I built a solution using PowerShell with Azure Functions for simple and complex requirements at my workplace. In this blog series, I would like to cover the most exciting experiences while deploying the solution.  The simple and complex issues are defined based on the environment and use cases, considering that this blog series has no justification for it!

To begin with, let me share a few how-tos!

How to change the port?

If you are running the Azure Functions in the localhost, the port is set to 7071 by default. The below settings allow us to change the port to the desired one.

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "powershell",
    "AzureWebJobsStorage": "{AzureWebJobsStorage}"
  },
  "Host": {
    "LocalHttpPort": 8080
  }
}

Is there any alternative approach? Yes, we can start the function using “–port” parameter

func start -port 8081

> Video for your reference!

How to change the route prefix?

Route prefix is nothing but a piece of the string associated with routes by design in the attribute, which is common in the entire controller. For example, look at the URL below where API is the route prefix

http://localhost:7071/api/iGreet

Here is the solution to change the route prefix!

{
  "version": "2.0",
  "managedDependency": {
    "enabled": false
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  },
  "extensions": {
    "http": {
      "routePrefix": "iAPI"
    }
  }
}

> Video for your reference!

How to extend function time out?

By default, Azure Functions run for 5 minutes, and then timeout occurs. However, it is feasible to extend to 10 minutes—the host.json needs a modification like illustrated below.

{
  "version": "2.0",
  "managedDependency": {
    "enabled": false
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  },
  "extensions": {
    "http": {
      "routePrefix": "iAPI"
    }
  },
  "functionTimeout": "00:10:00"
}

> Video for your reference!

Leave a Reply

Your e-mail address will not be published. Required fields are marked *