I build a lot of Angular apps. They all need data, and often I find myself building a Node server to host my API calls and serve my data. There is a lot of ceremony in setting up a web API, which is one reason why I have been interested in serverless functions. Enter Azure Functions, which are incredibly easy to get started to create some of your own APIs.

I'll be posting more about Angular apps and Azure Functions and my experiences with them, including some quickstarts.

Configuring

Azure Functions can be configured a few ways. One of the most flexible is to use JSON files.

When I set up an Azure Function, there are two key configuration files I often use: function.json and host.json. The entire Azure Function app service has one host.json file to configure the app. Every end-point function has its own configuration, defined in a function.json file. Pretty straightforward overall.

Now, I love JSON. It makes configuring the functions so easy ... except when I have to remember every setting. Ugh. This is where JSON schemas make a huge and positive difference in the development experience.

I use VS Code, which has an easy way to provide intellisense for JSON files. Fortunately, each of the Azure Functions JSON files has a defined schema in the popular GitHub repo https://github.com/SchemaStore/schemastore. This makes it easy to reference the schema from most modern code editors.

Identifying the JSON Schemas to VS Code

Add this json.schemas property to your settings.json file in VS Code.

"json.schemas": [
  {
    "fileMatch": [
      "/function.json"
    ],
    "url": "http://json.schemastore.org/function"
  },
  {
    "fileMatch": [
      "/host.json"
    ],
    "url": "http://json.schemastore.org/host"
  }
],

Once added, go back to a function.json file and we can see we get some help in the editor! This makes it easy to focus on writing the function code, and less on remembering every JSON property and its domain of values.

I'll follow up with more posts on how to create and configure Azure Functions. In the meantime, check out this post on using the Azure CLI with Azure Functions, by Shayne Boyer