- Have your code ready (e.g., Python, C#, JavaScript).
- Ensure you have the necessary Azure Function project structure.
- Install Azure CLI on your machine.
- Log in to your Azure account with:
az login
-
Go to the Azure Portal.
-
Create a Resource:
- Click Create a resource.
- Search for Function App and select it.
- Click Create.
-
Configure Basics:
- Subscription: Choose your subscription.
- Resource Group: Select or create a new resource group.
- Function App Name: Enter a globally unique name.
- Region: Choose a region close to your users.
- Runtime Stack: Select your language (e.g., Python, Node.js, .NET).
- Version: Pick the version matching your code.
- Operating System: Windows or Linux (Linux is common for Python).
-
Hosting Tab:
- Storage Account: Create a new or use an existing one.
- Leave other settings as default for most scenarios.
-
Review + Create:
- Review all settings.
- Click Create to deploy the Function App.
You can use either VS Code, Azure CLI, or directly from the Portal. Below is the Azure CLI method:
-
Navigate to your function app project folder.
-
Initialize the project (if not done):
func init --worker-runtime python func new # to create a function (e.g., HTTP trigger) -
Deploy to Azure:
func azure functionapp publish <YourFunctionAppName>
- By default, an HTTP Triggered function becomes a REST API endpoint.
- After deployment, go to your Function App in Azure Portal.
- Open "Functions" in the sidebar.
- Select your function (e.g.,
HttpTrigger1). - Go to "Code + Test" to verify code.
- Click "Get Function URL" at the top right.
- Copy the URL—this is your live API endpoint.
| Step | Action |
|---|---|
| Create app | Use Portal to create a Function App |
| Prepare code | Add HTTP Trigger in your code project |
| Deploy | Use VS Code or func azure functionapp publish |
| Test | Get Function URL, send a request (use Postman or curl) |
-
Use Postman or
curlto send a request:curl -X POST <FunctionURL> -H "Content-Type: application/json" -d '{"key":"value"}'
-
Confirm the response matches your expected output.
- Authentication: Enable Authentication/Authorization in the Portal if needed.
- CORS: Set allowed origins under "CORS" if the API is called from browsers.
- Monitoring: Use Application Insights (enable during setup or later) for logging and diagnostics.
- Use function/API keys for private endpoints.
- Store secrets (e.g., your Cognitive Services keys) in Azure Key Vault or environment settings in "Configuration".
- For advanced workflows, connect your GitHub repo or Azure Repo in the "Deployment Center" of your Function App for automated deployments.
Following these steps will provide you with a live, scalable Azure Function endpoint ready for use as an API in your AI-powered application.
Sources