Azure had made it easy to create serverless applications. They have named the serverless apps to "Functions" of which, there are two parts. First the Azure portal has an icon like this:
To create the function "host" in the cloud. In your Azure portal click on this icon.
From there click on Create...
You will see this screen:
The billing part of this is the subscription and the resource group. If you don't have a resource group you can click create new which merely asks for a name.
Runtime Stack
Here we see a runtime stack selection of .NET Core; however, there are many other stacks such as node.js which may be used.
✔️ Good so far, this sets up our portal side, look at this part as the definition of the container for our functions that will be published.
Create the Function
Back to the code side. We will use Visual Studio to create the function being that it will be in C#.
Open up Visual Studio and install or update 'Azure Functions'
Create a new project in Visual Studio
Select the Azure Functions Template
On the next screen "Configure your new project" set the name, location, solution, and solution name. Note: You may add this to another existing solution too.
Select HTTP trigger on next screen.
The Function Code
After clicking the 'Create' button shown above, the templated code will look like this:
Publish to Azure
Click on the BUILD tab in Visual Studio and select the option shown below.
Select Azure
Choose the Function Instance (container in Azure)
✔️ Done
To access the endpoint the url pattern is: /yourdomian/api/FunctionName in the url.
Conclusion
The term serverless is somewhat misleading because we had to tell it the server configuration, location etc. The 'serverless' part is that is was easy to do that, and we are only interested in using the new endpoint. From that perspective it is serverless with respect to maintain the platform function run. Perhaps the best part is that we can spin up a new function in 10 minutes.
JWP2021
Top comments (0)