Azure

Create the API resource to host the API function which will be an Azure App
Azure

Requirements

Azure Functions Core Tools

The Azure Functions extension for Visual Studio Code integrates with Azure Functions Core Tools so that you can run and debug your functions locally in Visual Studio Code using the Azure Functions runtime.

Link

Python Link

Visual Studio Code Link

Python Extension for Visual Studio Code Link

Azure Functions Extension for Visual Studio Code Link

Azure V3 Extension for Visual Studio Code Link

Overview

Azure Functions: This is a service that allows you to run small pieces of code, called “functions,” without worrying about the underlying infrastructure (like servers). It’s a way to run your code in the cloud.

Connecting to Other Services: Azure Functions can easily connect to other Azure services or resources. This means your function can interact with databases, storage, and other cloud services without you needing to write complex code to handle these connections.

Bindings: are like bridges between your function and other services or resources. They can be for input (getting data into your function) or output (sending data from your function to somewhere else). You set up these bindings in the function’s definition, which is like a blueprint for how the function should work.

Data as Parameters: When your function runs, it gets the data it needs through these bindings. The data shows up as parameters in your function, which are like inputs that your code can use.

Trigger: A trigger is a special type of input binding. It’s what starts (or “triggers”) your function. For example, your function might start running when a new file is uploaded to a storage account. Each function has exactly one trigger, but it can have many input and output bindings.

In summary, Azure Functions lets you run small, independent pieces of code in the cloud. It makes it easy to connect this code to other Azure services or resources through something called bindings, which supply data to your functions or send data from your functions to other places. A trigger is a specific kind of binding that starts the function.

Bindings

Azure Functions lets you connect Azure services and other resources to functions without having to write your own integration code. These bindings, which represent both input and output, are declared within the function definition. Data from bindings is provided to the function as parameters. A trigger is a special type of input binding. Although a function has only one trigger, it can have multiple input and output bindings.

References

Create a function in Azure with Python using Visual Studio Code

Connect Azure Functions to Azure Cosmos DB using Visual Studio Code

BELOW HERE IS LEGACY

Create the Azure App Service Plan

ResourceDescriptionValue
NameThis is the unique name of your function app. Azure uses this name to create a default URL for your functions, like https://{your_function_app_name}.azurewebsites.net.crcdev
Operating SystemThis is the unique name of your function app. Azure uses this name to create a default URL for your functions, like https://{your_function_app_name}.azurewebsites.net.linux
RegionThis is the unique name of your function app. Azure uses this name to create a default URL for your functions, like https://{your_function_app_name}.azurewebsites.net.West Europe
Pricing TierThis is the unique name of your function app. Azure uses this name to create a default URL for your functions, like https://{your_function_app_name}.azurewebsites.net.free
Zone RedundancyThis is the unique name of your function app. Azure uses this name to create a default URL for your functions, like https://{your_function_app_name}.azurewebsites.net.disabled

The creation of the Azure Function is mostly defined as specifying which runtime environment you wish to use and choosing a hosting plan based on your scaling requirements. This is serverless computing and at this stage, the creation of the resource, we’re defining the application service plan (how much compute we want and the payment plan) plus some technical details such as runtime environment.

To create the Azure Function App resource locate the Azure Function App blade and create a new Function App.

ResourceDescriptionValue
Function App NameThis is the unique name of your function app. Azure uses this name to create a default URL for your functions, like https://{your_function_app_name}.azurewebsites.net.crcdev
PublishThis determines whether you want to run your functions from a package file (Code) or from a Docker container (Docker). In most cases, especially for simple applications, the Code option is the easiest and most straightforward. The Docker option offers more flexibility and control over the runtime environment, as you can customize the Docker image used to run your functions.Code
Runtime StackSelect the correct runtime stack based on what type of code you are running.Python
VersionHere you select the version of the runtime stack. It’s generally recommended to use the latest supported version, unless you have specific requirements to use an older version. For Python, if you’re using a library or package that requires a specific version, you might choose that one.Latest
RegionThis is the geographical area where your function app will be hosted. Ideally, you should choose a region that is close to your users or other services your application is interacting with, to minimize latency.West Europe
Operating SystemYou can choose between Windows and Linux. For Python, it’s generally more common to use Linux, but you could use either depending on your needs and the limits of your Runtime stack of course.Linux
PlanThis is the hosting plan for your functions. You have three options: Consumption (Serverless), Premium, and App Service (Dedicated). The Consumption plan automatically allocates compute power when your function is running, and you only pay for the compute time you consume. This is the most cost-effective plan if you have sporadic workloads and don’t need your function to be always warm. The Premium plan provides the same dynamic scaling but with additional features like VNet connectivity and no cold start. The App Service plan provides you with dedicated resources, ideal for long-running and compute-intensive functions.Consumption
Storage AccountAn Azure storage account is needed to store the data your function app uses, like code files, triggers, and logs. You can create a new one or use an existing one.Choose
NetworkingFunction Apps can be provisioned with the inbound address being public to the internet or isolated to an Azure virtual network.Turn off public access
MonitoringAzure Monitor application insights is an Application Performance Management (APM) service for developers and DevOps professionals. Enable it below to automatically monitor your application. It will detect performance anomalies, and includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app.Off
DeploymentEnable GitHub Actions to continuously deploy your app.Disable
Last modified July 21, 2024: update (e2ae86c)