├── .github └── ISSUE_TEMPLATE │ ├── azure-functions-on-azure-container-apps---bug-report.md │ └── feature_request.md ├── CODE_OF_CONDUCT.md ├── FAQ.md ├── LICENSE ├── README.md ├── SECURITY.md ├── SUPPORT.md ├── Troubleshooting Guide.md └── samples ├── ACAKindfunctionapp ├── README.md └── main.bicep ├── AIAssistant └── ReadMe.md ├── AzurePipelineTasks ├── Func_on_ACA_DevOps_deployment.yml └── Readme.md ├── Biceptemplates ├── Func_on_ACA_Bicepdeploy.bicep ├── MI_VNET_sample │ ├── README.md │ ├── acaenv.bicep │ ├── common.bicep │ ├── functionapp.bicep │ ├── functionappAfterSI.bicep │ ├── index.bicep │ ├── index.bicepparam │ └── roleassignments.bicep └── MI_VNET_sample_native │ ├── README.md │ ├── aca.bicep │ ├── acaAfterSI.bicep │ ├── acaenv.bicep │ ├── common.bicep │ ├── index.bicep │ ├── index.bicepparam │ └── roleassignments.bicep ├── DurableFunctions ├── LocalFunctionProj │ ├── .dockerignore │ ├── .gitignore │ ├── .vscode │ │ └── extensions.json │ ├── Dockerfile │ ├── DurableFunctionsOrchestrationCSharp.cs │ ├── LocalFunctionProj.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ └── host.json ├── README.md └── media │ ├── http_start_orchestration.png │ ├── orchestration_instance_status.png │ └── sql_connection_string_portal.png ├── FastAPIHttpTrigger ├── .dockerignore ├── .funcignore ├── .gitignore ├── Dockerfile ├── WrapperFunction │ └── __init__.py ├── function_app.py ├── getting_started.md ├── host.json ├── local.settings.json ├── requirements.txt └── workflows │ └── azure-pipelines.yml ├── FunctionGHProj ├── .dockerignore ├── .gitignore ├── .vscode │ └── extensions.json ├── Dockerfile ├── FunctionGHProj.csproj ├── HttpGHExample.cs ├── Program.cs ├── Readme.md └── host.json ├── FunctionandSpringAppSample ├── .dockerignore ├── .gitignore ├── Dockerfile ├── Program.cs ├── Readme.md ├── ServiceBusExample.cs ├── ServiceBusProj.csproj ├── github_actions_workflow.yml ├── host.json ├── local.settings.json └── servicebuscale.js ├── GitHubActions ├── Func_on_ACA_GitHubAction_deployment.yml └── Readme.md ├── Java Samples ├── Readme.md └── httptrigger │ ├── Dockerfile │ ├── host.json │ ├── local.settings.json │ ├── pom.xml │ └── src │ ├── main │ └── java │ │ └── com │ │ └── microsoft │ │ └── Function.java │ └── test │ └── java │ └── com │ └── microsoft │ ├── FunctionTest.java │ └── HttpResponseMessageMock.java ├── Kafka Sample ├── .dockerignore ├── .gitignore ├── .vscode │ └── extensions.json ├── Dockerfile ├── KafkaExample │ ├── __init__.py │ ├── function.json │ └── readme.md ├── Readme.md ├── host.json └── requirements.txt ├── ServiceBus_GitHubActionSample ├── Dockerfile ├── Program.cs ├── README.md ├── ServiceBusExample.cs ├── ServiceBusProj.csproj ├── bin │ └── output │ │ ├── Azure.Core.dll │ │ ├── Google.Protobuf.dll │ │ ├── Grpc.Core.Api.dll │ │ ├── Grpc.Net.Client.dll │ │ ├── Grpc.Net.ClientFactory.dll │ │ ├── Grpc.Net.Common.dll │ │ ├── Microsoft.Azure.Functions.Worker.Core.dll │ │ ├── Microsoft.Azure.Functions.Worker.Extensions.Abstractions.dll │ │ ├── Microsoft.Azure.Functions.Worker.Extensions.ServiceBus.dll │ │ ├── Microsoft.Azure.Functions.Worker.Grpc.dll │ │ ├── Microsoft.Azure.Functions.Worker.dll │ │ ├── Microsoft.Bcl.AsyncInterfaces.dll │ │ ├── Microsoft.CodeAnalysis.CSharp.dll │ │ ├── Microsoft.CodeAnalysis.dll │ │ ├── Microsoft.Extensions.Configuration.Abstractions.dll │ │ ├── Microsoft.Extensions.Configuration.Binder.dll │ │ ├── Microsoft.Extensions.Configuration.CommandLine.dll │ │ ├── Microsoft.Extensions.Configuration.EnvironmentVariables.dll │ │ ├── Microsoft.Extensions.Configuration.FileExtensions.dll │ │ ├── Microsoft.Extensions.Configuration.Json.dll │ │ ├── Microsoft.Extensions.Configuration.UserSecrets.dll │ │ ├── Microsoft.Extensions.Configuration.dll │ │ ├── Microsoft.Extensions.DependencyInjection.Abstractions.dll │ │ ├── Microsoft.Extensions.DependencyInjection.dll │ │ ├── Microsoft.Extensions.FileProviders.Abstractions.dll │ │ ├── Microsoft.Extensions.FileProviders.Physical.dll │ │ ├── Microsoft.Extensions.FileSystemGlobbing.dll │ │ ├── Microsoft.Extensions.Hosting.Abstractions.dll │ │ ├── Microsoft.Extensions.Hosting.dll │ │ ├── Microsoft.Extensions.Http.dll │ │ ├── Microsoft.Extensions.Logging.Abstractions.dll │ │ ├── Microsoft.Extensions.Logging.Configuration.dll │ │ ├── Microsoft.Extensions.Logging.Console.dll │ │ ├── Microsoft.Extensions.Logging.Debug.dll │ │ ├── Microsoft.Extensions.Logging.EventLog.dll │ │ ├── Microsoft.Extensions.Logging.EventSource.dll │ │ ├── Microsoft.Extensions.Logging.dll │ │ ├── Microsoft.Extensions.Options.ConfigurationExtensions.dll │ │ ├── Microsoft.Extensions.Options.dll │ │ ├── Microsoft.Extensions.Primitives.dll │ │ ├── ServiceBusProj.deps.json │ │ ├── ServiceBusProj.dll │ │ ├── ServiceBusProj.exe │ │ ├── ServiceBusProj.pdb │ │ ├── ServiceBusProj.runtimeconfig.json │ │ ├── System.Diagnostics.EventLog.dll │ │ ├── System.Memory.Data.dll │ │ ├── cs │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── de │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── es │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── extensions.json │ │ ├── fr │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── functions.metadata │ │ ├── host.json │ │ ├── it │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── ja │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── ko │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── local.settings.json │ │ ├── pl │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── pt-BR │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── ru │ │ ├── Microsoft.CodeAnalysis.CSharp.resources.dll │ │ └── Microsoft.CodeAnalysis.resources.dll │ │ ├── runtimes │ │ └── win │ │ │ └── lib │ │ │ └── netcoreapp2.0 │ │ │ └── System.Diagnostics.EventLog.dll │ │ └── tr │ │ └── Microsoft.CodeAnalysis.CSharp.resources.dll ├── host.json ├── local.settings.json ├── obj │ ├── Debug │ │ └── net7.0 │ │ │ ├── ServiceBusProj.AssemblyInfo.cs │ │ │ ├── ServiceBusProj.AssemblyInfoInputs.cache │ │ │ ├── ServiceBusProj.GeneratedMSBuildEditorConfig.editorconfig │ │ │ ├── ServiceBusProj.GlobalUsings.g.cs │ │ │ ├── ServiceBusProj.assets.cache │ │ │ ├── ServiceBusProj.csproj.AssemblyReference.cache │ │ │ ├── ServiceBusProj.csproj.CopyComplete │ │ │ ├── ServiceBusProj.csproj.CoreCompileInputs.cache │ │ │ ├── ServiceBusProj.csproj.FileListAbsolute.txt │ │ │ ├── ServiceBusProj.dll │ │ │ ├── ServiceBusProj.genruntimeconfig.cache │ │ │ ├── ServiceBusProj.pdb │ │ │ ├── apphost.exe │ │ │ ├── ref │ │ │ └── ServiceBusProj.dll │ │ │ └── refint │ │ │ └── ServiceBusProj.dll │ ├── ServiceBusProj.csproj.nuget.dgspec.json │ ├── ServiceBusProj.csproj.nuget.g.props │ ├── ServiceBusProj.csproj.nuget.g.targets │ ├── project.assets.json │ └── project.nuget.cache ├── servicebuscale.js └── workflows │ └── main.yml ├── TimerTriggerSample ├── .dockerignore ├── .gitignore ├── Dockerfile ├── Program.cs ├── Readme.md ├── TimerProject.csproj ├── host.json └── timerfunc.cs ├── VSCode Sample └── Readme.md ├── VolumeMountsSample ├── README.md ├── code │ ├── .dockerignore │ ├── .funcignore │ ├── .gitignore │ ├── .vscode │ │ ├── extensions.json │ │ ├── launch.json │ │ ├── settings.json │ │ └── tasks.json │ ├── Dockerfile │ ├── function_app.py │ ├── host.json │ └── requirements.txt └── infra │ ├── index.bicep │ ├── index.bicepparam │ └── volumemount.bicep ├── azdsampleDAPRandFunctionsonACA ├── .azure │ └── config.json ├── .devcontainer │ └── devcontainer.json ├── CodeSample │ ├── CreateOrder │ │ ├── Dockerfile │ │ ├── components │ │ │ └── statestore.yml │ │ ├── extensions.csproj │ │ ├── function_app.py │ │ ├── getting_started.md │ │ ├── host.json │ │ ├── local.settings.json │ │ └── requirements.txt │ └── HttpFrontEnd │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── extensions.csproj │ │ ├── function_app.py │ │ ├── getting_started.md │ │ ├── host.json │ │ ├── local.settings.json │ │ └── requirements.txt ├── README.md ├── azure.yaml ├── infra │ ├── abbreviations.json │ ├── core │ │ └── function.bicep │ ├── main.bicep │ └── main.parameters.json └── samplerequest.py └── azdtemplates ├── .gitignore ├── README.md ├── azure.yaml └── infra ├── abbreviations.json ├── core └── function.bicep ├── main.bicep └── main.parameters.json /.github/ISSUE_TEMPLATE/azure-functions-on-azure-container-apps---bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Azure Functions on Azure Container Apps - Bug Report 3 | about: This will help create a bug report for Azure Functions on ACA 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Which trigger/binding are you using?** 11 | 12 | **Which language are you using?** 13 | 14 | **Provide resource details** 15 | 1. Function app name 16 | 2. Resource Id 17 | 18 | **Expected behavior** 19 | A clear and concise description of what you expected to happen. 20 | 21 | **Actual behavior** 22 | A clear and concise description of what you expected to happen. 23 | 24 | **To Reproduce** 25 | Steps to reproduce the behavior: 26 | 1. Go to '...' 27 | 2. Click on '....' 28 | 3. Scroll down to '....' 29 | 4. See error 30 | 31 | **Screenshots** 32 | If applicable, add screenshots to help explain your problem. 33 | 34 | **Logs** 35 | Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for improving Azure Functions on Azure Container apps 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # TODO: The maintainer of this repo has not yet edited this file 2 | 3 | **REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? 4 | 5 | - **No CSS support:** Fill out this template with information about how to file issues and get help. 6 | - **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. 7 | - **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. 8 | 9 | *Then remove this first heading from this SUPPORT.MD file before publishing your repo.* 10 | 11 | # Support 12 | 13 | ## How to file issues and get help 14 | 15 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing 16 | issues before filing new issues to avoid duplicates. For new issues, file your bug or 17 | feature request as a new Issue. 18 | 19 | For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE 20 | FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER 21 | CHANNEL. WHERE WILL YOU HELP PEOPLE?**. 22 | 23 | ## Microsoft Support Policy 24 | 25 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above. 26 | -------------------------------------------------------------------------------- /Troubleshooting Guide.md: -------------------------------------------------------------------------------- 1 | ## Troubleshooting Guide 2 | 3 | 4 | > ## 1) User assigned Managed Identity is only supported while deploying Azure Functions on Azure Container Apps using Microsoft.App RP and kind=functionapp. 5 | Note : System assigned Managed Identity will be enabled in April 2025 6 | While configuring user assigned Managed identity use __managedIdentityResourceId , __clientId support will be added soon by May 2025 7 | 8 | > ## 2) Cosmos dB scaling feature with connection string will be enabled in April 2025 and Managed Identity based scaling will estimated to be out by May 2025 9 | 10 | > ## 3) Azure Container Apps's Az Portal way of creating and deploying Azure Functions on Azure Container Apps will be released in April 2025. But you can still view the resource overview blades. 11 | Please note do not modify min/max replicas or environment variables from AzPortal or any operation that will result in a new revision creation. As there is a temporary issue that gets created on auto-scaling feature as a result of this. 12 | 13 | > ## 4) Please do not change/update the WEBSITE_AUTH_ENCRYPTION_KEY 14 | 15 | 16 | > ## 5) Post update of functionapp if scaling is not happening correctly, then manually synctrigger the functionapp. 17 | 18 | SyncTrigger can be done manually by either of these methods : 19 | 20 | a) Web Apps - Sync Function Triggers - REST API (Azure App Service) | Microsoft Learn 21 | b) Get 'defaultHostName' by doing a call on Sites - Get Site - REST API (Azure Azure Migrate) | Microsoft Learn 22 | Send an HTTP POST request to https:///admin/host/synctriggers?code= using the master key (Azure Functions HTTP trigger | Microsoft Learn). 23 | (You can also fetch the master key from StorageAccount>Containers>azure-webjobs-secrets>FunctionappName.) 24 | 25 | 26 | > 6) If you already have a appservice-kube extension installed then az functionapp create fails - unrecognized arguments: --environment –image –registry-username –registry-password 27 | 28 | In this case you need to uninstall the appservice-kube extension 29 | 30 | > 7) If for new ManagedEnvironment you see a failure for the first time create, please retry. 31 | 32 | > 8) Please do not remove the storage account from the appSettings of functionapp. 33 | 34 | > 9) Use FUNCTIONS_WOKER_RUNTIME="dotnet-isolated" for dotnet isolated based images. 35 | 36 | > 10) Incase you run into latest .net sdk not found issues run below command 37 | 38 | dotnet add package Microsoft.Azure.Functions.Worker.Sdk --version 1.7.0 39 | 40 | ## Below is applicable while deploying Azure Functions using Microsoft.Web resource provider 41 | >1) In case you see below error and trying to access underlying Azure Container Apps resource 42 | _The access is denied because of the deny assignment with name '605xxxxxxxxxxxxxx' and Id '605xxxxxxxx' at scope '/subscriptions/xxxxxxxxxxx/resourceGroups/mrgname '._ 43 | 44 | ## Solution 45 | Users are recommended not to delete/modify the underlying azure container apps resource. As this resource is locked down and will not allow user, group, or service principal to modify/update or deletes. 46 | This is to protect the function app resource from getting into an inconsistent state. 47 | 48 | >10) If you are facing issues with naming convention while using private docker registry. Please follow below guidance 49 | Provide --image with registry.hub.docker.com// . For more details refer to this [github discussion](https://github.com/Azure/azure-functions-on-container-apps/issues/66) 50 | 51 | az functionapp config container set ` 52 | --name ` 53 | --resource-group ` 54 | --image registry.hub.docker.com// ` 55 | --registry-server registry.hub.docker.com ` 56 | --registry-username ` 57 | --registry-password 58 | -------------------------------------------------------------------------------- /samples/ACAKindfunctionapp/README.md: -------------------------------------------------------------------------------- 1 | # Native Azure Functions on Azure Container Apps (ACA) Bicep Sample 2 | 3 | This repository provides a minimal Bicep template (`main.bicep`) to deploy Azure Functions natively on Azure Container Apps, along with a quick-start README. 4 | 5 | --- 6 | 7 | ## 1. Introduction 8 | 9 | Azure Container Apps now includes **native Azure Functions** support by setting the `kind=functionapp` property on a Container App resource. This enables you to combine the rich programming model and auto-scaling capabilities of Azure Functions with the flexible, serverless container hosting environment of Container Apps. 10 | - Read the official announcement blog post: 11 | https://techcommunity.microsoft.com/blog/AppsonAzureBlog/announcing-native-azure-functions-support-in-azure-container-apps/4414039 12 | - Learn more in the product documentation: 13 | https://learn.microsoft.com/en-us/azure/container-apps/functions-overview 14 | 15 | --- 16 | 17 | ## 2. Template Structure 18 | 19 | The provided `main.bicep` template does the following: 20 | 1. Creates a Log Analytics workspace for diagnostics and monitoring. 21 | 2. Provisions a Container Apps environment with Consumption‐based workload profile. 22 | 3. Deploys a Storage account and Application Insights for function host storage and telemetry. 23 | 4. Deploys the Functions Container app (with `kind=functionapp`) using the specified Docker image, runtime, and secrets. 24 | - The template uses a quickstart functions docker image. You can replace it with your own image that is compatible with Azure Functions host expectations - [Create a function app in a local Linux container](https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-container-registry). 25 | 5. Outputs the resource Id and fully qualified domain name (FQDN) endpoint of your Functions Container App. 26 | 27 | --- 28 | 29 | ## 3. Deployment 30 | 31 | 1. Clone or download the `main.bicep` file from the current folder. 32 | 33 | 1. Ensure you have the latest [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) and [Bicep CLI](https://learn.microsoft.com/azure/azure-resource-manager/bicep/install) installed. 34 | 35 | 1. Ensure the following Resource Providers are registered in your subscription: 36 | - Microsoft.App 37 | - Microsoft.OperationalInsights 38 | - Microsoft.Insights 39 | - Microsoft.Storage 40 | 41 | 1. Log in and select your target subscription and resource group: 42 | ```bash 43 | SUBSCRIPTION_ID="" 44 | RESOURCE_GROUP="" 45 | LOCATION="" 46 | az login 47 | az account set --subscription "$SUBSCRIPTION_ID" 48 | az group create --name "$RESOURCE_GROUP" --location "$LOCATION" 49 | ``` 50 | 51 | 1. Deploy the Bicep template using the Azure CLI: 52 | > [!WARNING] 53 | > This sample uses connection strings to keep the template lightweight. For production scenarios, it's strongly recommended to use [Managed Identity](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference?tabs=servicebus&pivots=programming-language-python#configure-an-identity-based-connection) for improved security and operational best practices. 54 | 55 | > **Note:** 56 | > All required parameters have default values, but you can override them by passing `--parameters` in the `az deployment group create` command. 57 | 58 | ```bash 59 | DEPLOYMENT_NAME="aca-functions-deployment" 60 | az deployment group create \ 61 | --name "$DEPLOYMENT_NAME" \ 62 | --resource-group "$RESOURCE_GROUP" \ 63 | --template-file main.bicep 64 | ``` 65 | View the deployment progress in the Azure portal or via the CLI. The deployment may take a few minutes to complete. 66 | 67 | 1. Access your Functions Container App: 68 | After deployment, the output will display the fully qualified domain name (FQDN) of your Functions Container App. You can also find it in the Azure portal under the **Container Apps** resource, listed with the type `Container App (Function)`. 69 | 70 | To test your function, you can use `curl` or any HTTP client: 71 | ```bash 72 | curl -X GET "https://...azurecontainerapps.io/api/" 73 | ``` 74 | 75 | 1. Clean up resources when done: 76 | ```bash 77 | az group delete --name "$RESOURCE_GROUP" --yes --no-wait 78 | ``` 79 | 80 | For additional customization, modify the `main.bicep` file accordingly. -------------------------------------------------------------------------------- /samples/AzurePipelineTasks/Func_on_ACA_DevOps_deployment.yml: -------------------------------------------------------------------------------- 1 | # This pipeline will build a container and deploy it to an Azure Functions App on Linux. 2 | # 3 | # This pipeline assumes you have already created the target Azure Functions app on Azure. 4 | # 5 | # To configure this pipeline: 6 | # Replace the following with correct values in this pipeline: 7 | # - your-registry 8 | # - your-namespace 9 | # - your-image-name 10 | # - your-subscription-id 11 | # - your-functionapp-name 12 | # 13 | # For more information on yaml pipelines: https://aka.ms/yaml 14 | 15 | trigger: 16 | - main 17 | 18 | pool: 19 | name: Azure Pipelines 20 | 21 | steps: 22 | - task: Docker@2 23 | displayName: Login 24 | inputs: 25 | containerRegistry: your-registry 26 | command: login 27 | 28 | - task: Docker@2 29 | displayName: build 30 | inputs: 31 | containerRegistry: your-registry 32 | repository: 'your-namespace/your-image-name' 33 | command: build 34 | 35 | - task: Docker@2 36 | displayName: push 37 | inputs: 38 | containerRegistry: your-registry 39 | repository: 'your-namespace/your-image-name' 40 | command: push 41 | 42 | - task: AzureFunctionAppContainer@1 43 | displayName: 'Azure Function App on Container Deploy' 44 | inputs: 45 | azureSubscription: 'your-subscription-id' 46 | appName: 'your-functionapp-name' 47 | imageName: 'your-namespace/your-image-name:$(Build.BuildId)' 48 | -------------------------------------------------------------------------------- /samples/AzurePipelineTasks/Readme.md: -------------------------------------------------------------------------------- 1 | # Deploy container to Azure Functions App using DevOps pipeline 2 | This pipeline will build a container and deploy it to an Azure Functions App on Linux. 3 | 4 | ## Pre-requisite 5 | This pipeline assumes you have already created the target Azure Functions app on Azure. 6 | 7 | ## To configure this pipeline: 8 | Replace the following with correct values in this pipeline: 9 | - your-registry 10 | - your-namespace 11 | - your-image-name 12 | - your-subscription-id 13 | - your-functionapp-name 14 | 15 | ## For more information on yaml pipelines: 16 | https://aka.ms/yaml 17 | -------------------------------------------------------------------------------- /samples/Biceptemplates/Func_on_ACA_Bicepdeploy.bicep: -------------------------------------------------------------------------------- 1 | param location string = resourceGroup().location 2 | 3 | 4 | 5 | @description('Resource name prefix') 6 | param resourceNamePrefix string 7 | var envResourceNamePrefix = toLower(resourceNamePrefix) 8 | 9 | /* ###################################################################### */ 10 | // Create storage account for function app prereq 11 | /* ###################################################################### */ 12 | resource azStorageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = { 13 | name: '${envResourceNamePrefix}storage' 14 | location: location 15 | kind: 'StorageV2' 16 | sku: { 17 | name: 'Standard_LRS' 18 | } 19 | } 20 | var azStorageConnectionString = 'DefaultEndpointsProtocol=https;AccountName=${azStorageAccount.name};EndpointSuffix=${az.environment().suffixes.storage};AccountKey=${azStorageAccount.listKeys().keys[0].value}' 21 | 22 | 23 | resource logAnalyticsWorkspace'Microsoft.OperationalInsights/workspaces@2021-06-01' = { 24 | name: '${envResourceNamePrefix}-la' 25 | location: location 26 | properties: any({ 27 | retentionInDays: 30 28 | features: { 29 | searchVersion: 1 30 | } 31 | sku: { 32 | name: 'PerGB2018' 33 | } 34 | }) 35 | } 36 | 37 | resource appInsights 'Microsoft.Insights/components@2020-02-02' = { 38 | name: '${envResourceNamePrefix}-ai' 39 | location: location 40 | kind: 'web' 41 | properties: { 42 | Application_Type: 'web' 43 | WorkspaceResourceId: logAnalyticsWorkspace.id 44 | } 45 | } 46 | 47 | resource environment 'Microsoft.App/managedEnvironments@2022-10-01' = { 48 | name: '${envResourceNamePrefix}-env' 49 | location: location 50 | properties: { 51 | daprAIInstrumentationKey: appInsights.properties.InstrumentationKey 52 | appLogsConfiguration: { 53 | destination: 'log-analytics' 54 | logAnalyticsConfiguration: { 55 | customerId: logAnalyticsWorkspace.properties.customerId 56 | sharedKey: logAnalyticsWorkspace.listKeys().primarySharedKey 57 | } 58 | } 59 | } 60 | } 61 | 62 | 63 | resource azfunctionapp 'Microsoft.Web/sites@2022-09-01' = { 64 | name: '${envResourceNamePrefix}-funcapp' 65 | location: location 66 | kind: 'functionapp' 67 | properties: { 68 | name: '${envResourceNamePrefix}-funcapp' 69 | managedEnvironmentId:environment.id 70 | siteConfig: { 71 | linuxFxVersion: 'Docker|mcr.microsoft.com/azure-functions/dotnet7-quickstart-demo:1.0' 72 | appSettings: [ 73 | { 74 | name: 'AzureWebJobsStorage' 75 | value: azStorageConnectionString 76 | } 77 | { 78 | name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' 79 | value: appInsights.properties.ConnectionString 80 | } 81 | ] 82 | 83 | } 84 | 85 | } 86 | } 87 | 88 | 89 | output functionAppName string = azfunctionapp.name 90 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample/README.md: -------------------------------------------------------------------------------- 1 | # Functions on ACA - MI, VNET sample 2 | 3 | ## Overview 4 | 5 | This is a sample project to get started with MI integration for Functions on ACA, and optionally enable VNet on the managed environment. 6 | 7 | For MI integration, it creates: 8 | - A keyvault, ACR, storage account and User assigned identity with necessary permissions on these resources 9 | - Assigns this identity to the function app. 10 | - Sets the right app settings and configuration on the function app to: 11 | - Use keyvault references 12 | - Pull images from private ACR 13 | - Access storage account without connection strings. 14 | - Set `useSystemIdentity` = `true`, in order to use system assigned identity instead of user managed identity in above steps. 15 | 16 | For VNet integration, it provides two flags in params: 17 | - hasVnet: To create and add a VNet to the managed environment. 18 | - isVnetInternal: To enable only internal Vnet traffic. 19 | By default, these flags are set to false. 20 | 21 | ## Resource creation 22 | 23 | - One of the ways to deploy these bicep templates is by opening them in vscode and [using bicep extension to deploy them](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/visual-studio-code?tabs=CLI#deploy-bicep-file). 24 | - After installing the bicep extension, right click on the `index.bicep` and choose `Deploy Bicep File...` 25 | 26 | Note: Each time this template is deployed, new resources get created with random strings. To consistently create or update the same set of resources, please set `prefix` parameter in `index.bicepparam` file to some unique string. 27 | 28 | ## Updating the image 29 | 30 | - This project creates the function app using default sample image: `mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0` 31 | - To use a private image, push your image to the ACR created above and update the function app config to use the private image. Function app would then pull the image in private acr using MI. 32 | 33 | ### Sample steps 34 | 35 | 1. Import your image to the private ACR created above: 36 | ``` 37 | az acr import \ 38 | --name \ 39 | --source mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0 \ 40 | --image azure-functions/dotnet8-quickstart-demo:1.0 41 | ``` 42 | Verify the image is imported correctly. 43 | 44 | 2. Update the image config on the function app to use private image:
45 | In the below command, update the linuxFxVersion by replacing function app name, resource group name and acr name appropriately. 46 | ``` 47 | az resource update \ 48 | -g \ 49 | -n /config/web \ 50 | --subscription \ 51 | --resource-type 'Microsoft.Web/sites/config' \ 52 | --set properties.linuxFxVersion="DOCKER|.azurecr.io/azure-functions/dotnet8-quickstart-demo:1.0" 53 | ``` 54 | Verify the linuxFxVersion is updated correctly, in JSON View in Portal. 55 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample/acaenv.bicep: -------------------------------------------------------------------------------- 1 | param prefix string 2 | param location string 3 | param hasVnet bool 4 | param isVnetInternal bool 5 | 6 | @description('Log Analytics workspace for ACA env') 7 | resource logws 'Microsoft.OperationalInsights/workspaces@2023-09-01' = { 8 | name: 'logws${uniqueString(prefix, subscription().id)}' 9 | location: location 10 | properties: { 11 | sku: { 12 | name: 'PerGB2018' 13 | } 14 | } 15 | } 16 | 17 | @description('VNET for ACA env') 18 | resource vnet 'Microsoft.Network/virtualNetworks@2023-09-01' = { 19 | name: 'vnet${uniqueString(prefix, subscription().id)}' 20 | location: location 21 | properties:{ 22 | addressSpace: { 23 | addressPrefixes: [ 24 | '10.0.0.0/16' 25 | ] 26 | } 27 | subnets: [ 28 | { 29 | name: 'subnet${uniqueString(prefix, subscription().id)}' 30 | properties: { 31 | addressPrefix: '10.0.0.0/23' 32 | delegations: [ 33 | { 34 | name: 'Microsoft.App/environments' 35 | properties: { 36 | serviceName: 'Microsoft.App/environments' 37 | } 38 | } 39 | ] 40 | } 41 | } 42 | ] 43 | } 44 | } 45 | 46 | @description('ACA env with vnet') 47 | resource vNetEnv 'Microsoft.App/managedEnvironments@2023-05-01' = if (hasVnet) { 48 | name: 'vnetenv${uniqueString(prefix, subscription().id)}' 49 | location: location 50 | properties: { 51 | appLogsConfiguration: { 52 | destination: 'log-analytics' 53 | logAnalyticsConfiguration: { 54 | customerId: logws.properties.customerId 55 | sharedKey: logws.listKeys().primarySharedKey 56 | } 57 | } 58 | workloadProfiles: [ 59 | { 60 | name: 'Consumption' 61 | workloadProfileType: 'consumption' 62 | } 63 | { 64 | name: 'd4' 65 | workloadProfileType: 'D4' 66 | minimumCount: 1 67 | maximumCount: 3 68 | } 69 | ] 70 | vnetConfiguration: { 71 | infrastructureSubnetId: vnet.properties.subnets[0].id 72 | internal: isVnetInternal 73 | } 74 | } 75 | } 76 | 77 | @description('ACA env without vnet') 78 | resource env 'Microsoft.App/managedEnvironments@2023-05-01' = if (!hasVnet) { 79 | name: 'env${uniqueString(prefix, subscription().id)}' 80 | location: location 81 | properties: { 82 | appLogsConfiguration: { 83 | destination: 'log-analytics' 84 | logAnalyticsConfiguration: { 85 | customerId: logws.properties.customerId 86 | sharedKey: logws.listKeys().primarySharedKey 87 | } 88 | } 89 | workloadProfiles: [ 90 | { 91 | name: 'Consumption' 92 | workloadProfileType: 'consumption' 93 | } 94 | { 95 | name: 'd4' 96 | workloadProfileType: 'D4' 97 | minimumCount: 1 98 | maximumCount: 3 99 | } 100 | ] 101 | } 102 | } 103 | 104 | output envId string = hasVnet ? vNetEnv.id : env.id 105 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample/common.bicep: -------------------------------------------------------------------------------- 1 | param prefix string 2 | param location string 3 | param createUMI bool 4 | 5 | @description('Host storage account') 6 | resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = { 7 | name: 'storage${uniqueString(prefix, subscription().id)}' 8 | location: location 9 | kind: 'StorageV2' 10 | sku: { 11 | name: 'Standard_LRS' 12 | } 13 | properties: { 14 | } 15 | } 16 | 17 | @description('Queue service') 18 | resource queueService 'Microsoft.Storage/storageAccounts/queueServices@2023-01-01' = { 19 | parent: storage 20 | name: 'default' 21 | } 22 | 23 | @description('Queue for queue trigger') 24 | resource inputQueue 'Microsoft.Storage/storageAccounts/queueServices/queues@2023-01-01' = { 25 | parent: queueService 26 | name: 'inputqueue' 27 | } 28 | 29 | @description('Queue for queue output binding') 30 | resource outputQueue 'Microsoft.Storage/storageAccounts/queueServices/queues@2023-01-01' = { 31 | parent: queueService 32 | name: 'outputqueue' 33 | } 34 | 35 | 36 | @description('Container registry for images') 37 | resource acr 'Microsoft.ContainerRegistry/registries@2023-07-01' = { 38 | name: 'acr${uniqueString(prefix, subscription().id)}' 39 | location: location 40 | sku: { 41 | name: 'Basic' 42 | } 43 | } 44 | 45 | @description('Key vault for key vault references') 46 | resource vault 'Microsoft.KeyVault/vaults@2021-11-01-preview' = { 47 | name: 'kv${uniqueString(prefix, subscription().id)}' 48 | location: location 49 | properties: { 50 | accessPolicies:[] 51 | enableRbacAuthorization: true 52 | enableSoftDelete: true 53 | softDeleteRetentionInDays: 90 54 | enabledForDeployment: false 55 | enabledForDiskEncryption: false 56 | enabledForTemplateDeployment: false 57 | tenantId: subscription().tenantId 58 | sku: { 59 | name: 'standard' 60 | family: 'A' 61 | } 62 | networkAcls: { 63 | defaultAction: 'Allow' 64 | bypass: 'AzureServices' 65 | } 66 | } 67 | } 68 | 69 | resource secret 'Microsoft.KeyVault/vaults/secrets@2023-07-01' = { 70 | parent: vault 71 | name: 'mysecret' 72 | properties: { 73 | value: 'Hello, World!' 74 | } 75 | } 76 | 77 | @description('Identity for all operations') 78 | resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = if(createUMI) { 79 | name: 'identity${uniqueString(prefix, subscription().id)}' 80 | location: location 81 | } 82 | 83 | output acrUrl string = acr.properties.loginServer 84 | output storageName string = storage.name 85 | output vaultUri string = vault.properties.vaultUri 86 | output identityResourceId string = createUMI ? identity.id: '' 87 | output identityClientId string = createUMI ? identity.properties.clientId: '' 88 | output identityPrincipalId string = createUMI ? identity.properties.principalId: '' 89 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample/functionapp.bicep: -------------------------------------------------------------------------------- 1 | param prefix string 2 | param appLocation string 3 | 4 | param acrUrl string 5 | param storageName string 6 | param vaultUri string 7 | param envId string 8 | param identityResourceId string 9 | param identityClientId string 10 | param useSystemIdentity bool 11 | 12 | var identityInfo = useSystemIdentity ? { 13 | type: 'SystemAssigned' 14 | }: { 15 | type: 'UserAssigned' 16 | userAssignedIdentities: { 17 | '${identityResourceId}': {} 18 | } 19 | } 20 | 21 | var appsettings = useSystemIdentity ? [ 22 | { 23 | name: 'DOCKER_REGISTRY_SERVER_URL' 24 | value: acrUrl 25 | } 26 | { 27 | name: 'AzureWebJobsStorage__accountName' 28 | value: storageName 29 | } 30 | /* { 31 | name: 'keyVaultSecret' 32 | value: '@Microsoft.KeyVault(SecretUri=${vaultUri}secrets/mysecret)' 33 | } */ 34 | ]: [ 35 | { 36 | name: 'DOCKER_REGISTRY_SERVER_URL' 37 | value: acrUrl 38 | } 39 | { 40 | name: 'AzureWebJobsStorage__credential' 41 | value: 'managedidentity' 42 | } 43 | { 44 | name: 'AzureWebJobsStorage__clientId' 45 | value: identityClientId 46 | } 47 | { 48 | name: 'AzureWebJobsStorage__accountName' 49 | value: storageName 50 | } 51 | { 52 | name: 'keyVaultSecret' 53 | value: '@Microsoft.KeyVault(SecretUri=${vaultUri}secrets/mysecret)' 54 | } 55 | ] 56 | 57 | resource functionapp 'Microsoft.Web/sites@2023-01-01' = { 58 | name: 'func1-${uniqueString(prefix, subscription().id)}' 59 | location: appLocation 60 | kind: 'functionapp,linux,container,azurecontainerapps' 61 | identity: identityInfo 62 | properties: { 63 | keyVaultReferenceIdentity: useSystemIdentity ? '': identityResourceId 64 | managedEnvironmentId: envId 65 | siteConfig: { 66 | linuxFxVersion: 'DOCKER|mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0' 67 | acrUseManagedIdentityCreds: !useSystemIdentity 68 | acrUserManagedIdentityID: useSystemIdentity ? '': identityResourceId 69 | minimumElasticInstanceCount: 1 70 | functionAppScaleLimit: 5 71 | appSettings: appsettings 72 | } 73 | } 74 | } 75 | 76 | 77 | module faroleassignments 'roleassignments.bicep' = if (useSystemIdentity) { 78 | name: 'faroleassignments' 79 | params: { 80 | prefix: prefix 81 | principalId: functionapp.identity.principalId 82 | } 83 | } 84 | 85 | output functionappName string = functionapp.name 86 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample/functionappAfterSI.bicep: -------------------------------------------------------------------------------- 1 | param appName string 2 | param appLocation string 3 | param acrUrl string 4 | 5 | resource functionapp 'Microsoft.Web/sites@2023-01-01' = { 6 | name: appName 7 | location: appLocation 8 | kind: 'functionapp,linux,container,azurecontainerapps' 9 | properties: { 10 | siteConfig: { 11 | linuxFxVersion: 'DOCKER|mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0' 12 | acrUseManagedIdentityCreds: true 13 | appSettings: [ 14 | { 15 | name: 'DOCKER_REGISTRY_SERVER_URL' 16 | value: acrUrl 17 | } 18 | ] 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample/index.bicep: -------------------------------------------------------------------------------- 1 | targetScope = 'subscription' 2 | 3 | param prefix string = newGuid() 4 | param location string 5 | param hasVnet bool = false 6 | param isVnetInternal bool = false 7 | param useSystemIdentity bool = false 8 | 9 | resource rg 'Microsoft.Resources/resourceGroups@2023-07-01' = { 10 | name: '${prefix}-rg' 11 | location: location 12 | } 13 | 14 | module common 'common.bicep' = { 15 | name: 'common' 16 | scope: rg 17 | params: { 18 | prefix: prefix 19 | location: location 20 | createUMI: !useSystemIdentity 21 | } 22 | } 23 | 24 | module roleassignments 'roleassignments.bicep' = if (!useSystemIdentity) { 25 | name: 'roleassignments' 26 | scope: rg 27 | params: { 28 | prefix: prefix 29 | principalId: common.outputs.identityPrincipalId 30 | } 31 | } 32 | 33 | module acaenv 'acaenv.bicep' = { 34 | name: 'acaenv' 35 | scope: rg 36 | params: { 37 | prefix: prefix 38 | location: location 39 | hasVnet: hasVnet 40 | isVnetInternal: isVnetInternal 41 | } 42 | } 43 | 44 | module functionapp 'functionapp.bicep' = { 45 | name: 'functionapp' 46 | scope: rg 47 | params: { 48 | prefix: prefix 49 | appLocation: location 50 | acrUrl: common.outputs.acrUrl 51 | storageName: common.outputs.storageName 52 | vaultUri: common.outputs.vaultUri 53 | identityResourceId: common.outputs.identityResourceId 54 | identityClientId: common.outputs.identityClientId 55 | envId: acaenv.outputs.envId 56 | useSystemIdentity: useSystemIdentity 57 | } 58 | } 59 | 60 | // redeploy function app to set acr creds after role assignments are done for system identity. 61 | /* module functionappAfterSI 'functionappAfterSI.bicep' = if (useSystemIdentity){ 62 | name: 'functionappAfterSI' 63 | scope: rg 64 | params: { 65 | appLocation: location 66 | appName: functionapp.outputs.functionappName 67 | acrUrl: common.outputs.acrUrl 68 | } 69 | } */ 70 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample/index.bicepparam: -------------------------------------------------------------------------------- 1 | using './index.bicep' 2 | 3 | // Location to create the resources in. 4 | param location = 'westcentralus' 5 | 6 | // Set this param to unique value to get consistent resources everytime deployed. 7 | // param prefix = '' 8 | 9 | // set these flags to true to enable Vnet, and Vnet Internal. 10 | param hasVnet = false 11 | param isVnetInternal = false 12 | 13 | // set this to true to use system assigned identity 14 | param useSystemIdentity = false 15 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample/roleassignments.bicep: -------------------------------------------------------------------------------- 1 | 2 | param prefix string 3 | param principalId string 4 | 5 | // Role Definitions 6 | resource acrPullRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 7 | name: '7f951dda-4ed3-4680-a7ca-43fe172d538d' 8 | } 9 | 10 | resource storageBlobDataOwnerRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 11 | name: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b' 12 | } 13 | 14 | resource storageQueueDataReaderRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 15 | name: '19e7f393-937e-4f77-808e-94535e297925' 16 | } 17 | 18 | resource storageQueueProcessorRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 19 | name: '8a0f0c08-91a1-4084-bc3d-661d67233fed' 20 | } 21 | 22 | resource storageQueueContributorRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 23 | name: '974c5e8b-45b9-4653-ba55-5f855dd0fb88' 24 | } 25 | 26 | resource storageQueueSenderRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 27 | name: 'c6a89b2d-59bc-44d0-9896-0f6e12d7b80a' 28 | } 29 | 30 | resource keyVaultSecretOfficerRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 31 | name: 'b86a8fe4-44ce-4948-aee5-eccb2c155cd7' 32 | } 33 | 34 | resource keyVaultSecretUserRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 35 | name: '4633458b-17de-408a-b874-0445c86b69e6' 36 | } 37 | 38 | 39 | // Role Assignments 40 | resource acrPullRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 41 | name: guid(prefix, acrPullRoleDef.id) 42 | properties: { 43 | roleDefinitionId: acrPullRoleDef.id 44 | principalId: principalId 45 | principalType: 'ServicePrincipal' 46 | } 47 | } 48 | 49 | resource storageBlobDataOwnerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 50 | name: guid(prefix, storageBlobDataOwnerRoleDef.id) 51 | properties: { 52 | roleDefinitionId: storageBlobDataOwnerRoleDef.id 53 | principalId: principalId 54 | principalType: 'ServicePrincipal' 55 | } 56 | } 57 | 58 | resource storageQueueDataReaderRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 59 | name: guid(prefix, storageQueueDataReaderRoleDef.id) 60 | properties: { 61 | roleDefinitionId: storageQueueDataReaderRoleDef.id 62 | principalId: principalId 63 | principalType: 'ServicePrincipal' 64 | } 65 | } 66 | 67 | resource storageQueueProcessorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 68 | name: guid(prefix, storageQueueProcessorRoleDef.id) 69 | properties: { 70 | roleDefinitionId: storageQueueProcessorRoleDef.id 71 | principalId: principalId 72 | principalType: 'ServicePrincipal' 73 | } 74 | } 75 | 76 | resource storageQueueContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 77 | name: guid(prefix, storageQueueContributorRoleDef.id) 78 | properties: { 79 | roleDefinitionId: storageQueueContributorRoleDef.id 80 | principalId: principalId 81 | principalType: 'ServicePrincipal' 82 | } 83 | } 84 | 85 | resource storageQueueSenderignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 86 | name: guid(prefix, storageQueueSenderRoleDef.id) 87 | properties: { 88 | roleDefinitionId: storageQueueSenderRoleDef.id 89 | principalId: principalId 90 | principalType: 'ServicePrincipal' 91 | } 92 | } 93 | 94 | resource keyVaultSecretOfficerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 95 | name: guid(prefix, keyVaultSecretOfficerRoleDef.id) 96 | properties: { 97 | roleDefinitionId: keyVaultSecretOfficerRoleDef.id 98 | principalId: principalId 99 | principalType: 'ServicePrincipal' 100 | } 101 | } 102 | 103 | resource keyVaultSecretUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 104 | name: guid(prefix, keyVaultSecretUserRoleDef.id) 105 | properties: { 106 | roleDefinitionId: keyVaultSecretUserRoleDef.id 107 | principalId: principalId 108 | principalType: 'ServicePrincipal' 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample_native/README.md: -------------------------------------------------------------------------------- 1 | # Functions on ACA - MI, VNET sample 2 | 3 | ## Overview 4 | 5 | This is a sample project to get started with MI integration for Functions on ACA natively, and optionally enable VNet on the managed environment. 6 | 7 | For MI integration, it creates: 8 | - A keyvault, ACR, storage account and User assigned identity with necessary permissions on these resources 9 | - Assigns this identity to the function app. 10 | - Sets the right app settings and configuration on the function app to: 11 | - Use keyvault references 12 | - Pull images from private ACR 13 | - Access storage account without connection strings. 14 | - Set `useSystemIdentity` = `true`, in order to use system assigned identity instead of user managed identity in above steps. 15 | 16 | For VNet integration, it provides two flags in params: 17 | - hasVnet: To create and add a VNet to the managed environment. 18 | - isVnetInternal: To enable only internal Vnet traffic. 19 | By default, these flags are set to false. 20 | 21 | ## Resource creation 22 | 23 | - One of the ways to deploy these bicep templates is by opening them in vscode and [using bicep extension to deploy them](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/visual-studio-code?tabs=CLI#deploy-bicep-file). 24 | - After installing the bicep extension, right click on the `index.bicep` and choose `Deploy Bicep File...` 25 | 26 | Note: Each time this template is deployed, new resources get created with random strings. To consistently create or update the same set of resources, please set `prefix` parameter in `index.bicepparam` file to some unique string. 27 | 28 | ## Updating the image 29 | 30 | - This project creates the function app using default sample image: `mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0` 31 | - To use a private image, push your image to the ACR created above and update the function app config to use the private image. Function app would then pull the image in private acr using MI. 32 | 33 | ### Sample steps 34 | 35 | 1. Import your image to the private ACR created above: 36 | ``` 37 | az acr import \ 38 | --name \ 39 | --source mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0 \ 40 | --image azure-functions/dotnet8-quickstart-demo:1.0 41 | ``` 42 | Verify the image is imported correctly. 43 | 44 | 2. Update the image config on the function app to use private image:
45 | You can go to portal for the container app, and go to container configuration section and choose the ACR and the image. 46 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample_native/aca.bicep: -------------------------------------------------------------------------------- 1 | param prefix string 2 | param appLocation string 3 | 4 | param acrUrl string 5 | param storageName string 6 | param vaultUri string 7 | param envId string 8 | param identityResourceId string 9 | param identityClientId string 10 | param useSystemIdentity bool 11 | 12 | var identityInfo = useSystemIdentity ? { 13 | type: 'SystemAssigned' 14 | }: { 15 | type: 'UserAssigned' 16 | userAssignedIdentities: { 17 | '${identityResourceId}': {} 18 | } 19 | } 20 | 21 | var envVars = useSystemIdentity ? [ 22 | { 23 | name: 'AzureWebJobsStorage__accountName' 24 | value: storageName 25 | } 26 | /* { 27 | name: 'keyVaultSecret' 28 | value: '@Microsoft.KeyVault(SecretUri=${vaultUri}secrets/mysecret)' 29 | } */ 30 | ]: [ 31 | { 32 | name: 'AzureWebJobsStorage__credential' 33 | value: 'managedidentity' 34 | } 35 | { 36 | name: 'AzureWebJobsStorage__clientId' 37 | value: identityClientId 38 | } 39 | { 40 | name: 'AzureWebJobsStorage__accountName' 41 | value: storageName 42 | } 43 | ] 44 | 45 | var registries = useSystemIdentity ? null: [ 46 | { 47 | server: acrUrl 48 | identity: identityResourceId 49 | } 50 | ] 51 | 52 | resource containerApp 'Microsoft.App/containerApps@2024-02-02-preview' = { 53 | name: 'func1-${uniqueString(prefix, subscription().id)}' 54 | kind: 'functionapp' 55 | location: appLocation 56 | identity: identityInfo 57 | properties: { 58 | managedEnvironmentId: envId 59 | configuration: { 60 | registries: registries 61 | ingress:{ 62 | external: true 63 | targetPort: 80 64 | } 65 | } 66 | template: { 67 | containers: [ 68 | { 69 | image: 'mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0' 70 | name: 'function-container' 71 | env: envVars 72 | resources: { 73 | cpu: 1 74 | memory: '2Gi' 75 | } 76 | } 77 | ] 78 | scale: { 79 | minReplicas: 1 80 | } 81 | } 82 | } 83 | } 84 | 85 | output fqdn string = containerApp.properties.configuration.ingress.fqdn 86 | 87 | 88 | module faroleassignments 'roleassignments.bicep' = if (useSystemIdentity) { 89 | name: 'faroleassignments' 90 | params: { 91 | prefix: prefix 92 | principalId: containerApp.identity.principalId 93 | } 94 | } 95 | 96 | output functionappName string = containerApp.name 97 | 98 | 99 | // redeploy function app to set acr creds after role assignments are done for system identity. 100 | module functionappAfterSI 'acaAfterSI.bicep' = if (useSystemIdentity){ 101 | name: 'containerappAfterSI' 102 | params: { 103 | appLocation: appLocation 104 | appName: containerApp.name 105 | acrUrl: acrUrl 106 | envId: envId 107 | identityInfo: identityInfo 108 | envVars: envVars 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample_native/acaAfterSI.bicep: -------------------------------------------------------------------------------- 1 | param appName string 2 | param appLocation string 3 | param acrUrl string 4 | param envId string 5 | param identityInfo object 6 | param envVars object[] 7 | 8 | resource containerApp 'Microsoft.App/containerApps@2024-02-02-preview' = { 9 | name: appName 10 | kind: 'functionapp' 11 | location: appLocation 12 | identity: identityInfo 13 | properties: { 14 | managedEnvironmentId: envId 15 | configuration: { 16 | registries: [ 17 | { 18 | server: acrUrl 19 | identity: 'system' 20 | } 21 | ] 22 | ingress:{ 23 | external: true 24 | targetPort: 80 25 | } 26 | } 27 | template: { 28 | containers: [ 29 | { 30 | image: 'mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0' 31 | name: 'function-container' 32 | env: envVars 33 | resources: { 34 | cpu: 1 35 | memory: '2Gi' 36 | } 37 | } 38 | ] 39 | scale: { 40 | minReplicas: 1 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample_native/acaenv.bicep: -------------------------------------------------------------------------------- 1 | param prefix string 2 | param location string 3 | param hasVnet bool 4 | param isVnetInternal bool 5 | 6 | @description('Log Analytics workspace for ACA env') 7 | resource logws 'Microsoft.OperationalInsights/workspaces@2023-09-01' = { 8 | name: 'logws${uniqueString(prefix, subscription().id)}' 9 | location: 'centralus' 10 | properties: { 11 | sku: { 12 | name: 'PerGB2018' 13 | } 14 | } 15 | } 16 | 17 | @description('VNET for ACA env') 18 | resource vnet 'Microsoft.Network/virtualNetworks@2023-09-01' = { 19 | name: 'vnet${uniqueString(prefix, subscription().id)}' 20 | location: location 21 | properties:{ 22 | addressSpace: { 23 | addressPrefixes: [ 24 | '10.0.0.0/16' 25 | ] 26 | } 27 | subnets: [ 28 | { 29 | name: 'subnet${uniqueString(prefix, subscription().id)}' 30 | properties: { 31 | addressPrefix: '10.0.0.0/23' 32 | delegations: [ 33 | { 34 | name: 'Microsoft.App/environments' 35 | properties: { 36 | serviceName: 'Microsoft.App/environments' 37 | } 38 | } 39 | ] 40 | } 41 | } 42 | ] 43 | } 44 | } 45 | 46 | @description('ACA env with vnet') 47 | resource vNetEnv 'Microsoft.App/managedEnvironments@2023-05-01' = if (hasVnet) { 48 | name: 'vnetenv${uniqueString(prefix, subscription().id)}' 49 | location: location 50 | properties: { 51 | appLogsConfiguration: { 52 | destination: 'log-analytics' 53 | logAnalyticsConfiguration: { 54 | customerId: logws.properties.customerId 55 | sharedKey: logws.listKeys().primarySharedKey 56 | } 57 | } 58 | workloadProfiles: [ 59 | { 60 | name: 'Consumption' 61 | workloadProfileType: 'consumption' 62 | } 63 | { 64 | name: 'd4' 65 | workloadProfileType: 'D4' 66 | minimumCount: 1 67 | maximumCount: 3 68 | } 69 | ] 70 | vnetConfiguration: { 71 | infrastructureSubnetId: vnet.properties.subnets[0].id 72 | internal: isVnetInternal 73 | } 74 | } 75 | } 76 | 77 | @description('ACA env without vnet') 78 | resource env 'Microsoft.App/managedEnvironments@2023-05-01' = if (!hasVnet) { 79 | name: 'env${uniqueString(prefix, subscription().id)}' 80 | location: location 81 | properties: { 82 | appLogsConfiguration: { 83 | destination: 'log-analytics' 84 | logAnalyticsConfiguration: { 85 | customerId: logws.properties.customerId 86 | sharedKey: logws.listKeys().primarySharedKey 87 | } 88 | } 89 | workloadProfiles: [ 90 | { 91 | name: 'Consumption' 92 | workloadProfileType: 'consumption' 93 | } 94 | { 95 | name: 'd4' 96 | workloadProfileType: 'D4' 97 | minimumCount: 1 98 | maximumCount: 3 99 | } 100 | ] 101 | } 102 | } 103 | 104 | output envId string = hasVnet ? vNetEnv.id : env.id 105 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample_native/common.bicep: -------------------------------------------------------------------------------- 1 | param prefix string 2 | param location string 3 | param createUMI bool 4 | 5 | @description('Host storage account') 6 | resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = { 7 | name: 'storage${uniqueString(prefix, subscription().id)}' 8 | location: location 9 | kind: 'StorageV2' 10 | sku: { 11 | name: 'Standard_LRS' 12 | } 13 | properties: { 14 | allowBlobPublicAccess: false 15 | } 16 | } 17 | 18 | @description('Queue service') 19 | resource queueService 'Microsoft.Storage/storageAccounts/queueServices@2023-01-01' = { 20 | parent: storage 21 | name: 'default' 22 | } 23 | 24 | @description('Queue for queue trigger') 25 | resource inputQueue 'Microsoft.Storage/storageAccounts/queueServices/queues@2023-01-01' = { 26 | parent: queueService 27 | name: 'inputqueue' 28 | } 29 | 30 | @description('Queue for queue output binding') 31 | resource outputQueue 'Microsoft.Storage/storageAccounts/queueServices/queues@2023-01-01' = { 32 | parent: queueService 33 | name: 'outputqueue' 34 | } 35 | 36 | 37 | @description('Container registry for images') 38 | resource acr 'Microsoft.ContainerRegistry/registries@2023-07-01' = { 39 | name: 'acr${uniqueString(prefix, subscription().id)}' 40 | location: location 41 | sku: { 42 | name: 'Basic' 43 | } 44 | } 45 | 46 | @description('Key vault for key vault references') 47 | resource vault 'Microsoft.KeyVault/vaults@2021-11-01-preview' = { 48 | name: 'kv${uniqueString(prefix, subscription().id)}' 49 | location: location 50 | properties: { 51 | accessPolicies:[] 52 | enableRbacAuthorization: true 53 | enableSoftDelete: true 54 | softDeleteRetentionInDays: 90 55 | enabledForDeployment: false 56 | enabledForDiskEncryption: false 57 | enabledForTemplateDeployment: false 58 | tenantId: subscription().tenantId 59 | sku: { 60 | name: 'standard' 61 | family: 'A' 62 | } 63 | networkAcls: { 64 | defaultAction: 'Allow' 65 | bypass: 'AzureServices' 66 | } 67 | } 68 | } 69 | 70 | resource secret 'Microsoft.KeyVault/vaults/secrets@2023-07-01' = { 71 | parent: vault 72 | name: 'mysecret' 73 | properties: { 74 | value: 'Hello, World!' 75 | } 76 | } 77 | 78 | @description('Identity for all operations') 79 | resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = if(createUMI) { 80 | name: 'identity${uniqueString(prefix, subscription().id)}' 81 | location: location 82 | } 83 | 84 | output acrUrl string = acr.properties.loginServer 85 | output storageName string = storage.name 86 | output vaultUri string = vault.properties.vaultUri 87 | output identityResourceId string = createUMI ? identity.id: '' 88 | output identityClientId string = createUMI ? identity.properties.clientId: '' 89 | output identityPrincipalId string = createUMI ? identity.properties.principalId: '' 90 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample_native/index.bicep: -------------------------------------------------------------------------------- 1 | targetScope = 'subscription' 2 | 3 | param prefix string = 'vinfunc${newGuid()}' 4 | param location string 5 | param hasVnet bool = false 6 | param isVnetInternal bool = false 7 | param useSystemIdentity bool = false 8 | 9 | resource rg 'Microsoft.Resources/resourceGroups@2023-07-01' = { 10 | name: '${prefix}-rg' 11 | location: location 12 | } 13 | 14 | module common 'common.bicep' = { 15 | name: 'common' 16 | scope: rg 17 | params: { 18 | prefix: prefix 19 | location: location 20 | createUMI: !useSystemIdentity 21 | } 22 | } 23 | 24 | module roleassignments 'roleassignments.bicep' = if (!useSystemIdentity) { 25 | name: 'roleassignments' 26 | scope: rg 27 | params: { 28 | prefix: prefix 29 | principalId: common.outputs.identityPrincipalId 30 | } 31 | } 32 | 33 | module acaenv 'acaenv.bicep' = { 34 | name: 'acaenv' 35 | scope: rg 36 | params: { 37 | prefix: prefix 38 | location: location 39 | hasVnet: hasVnet 40 | isVnetInternal: isVnetInternal 41 | } 42 | } 43 | 44 | module containerapp 'aca.bicep' = { 45 | name: 'containerapp' 46 | scope: rg 47 | params: { 48 | prefix: prefix 49 | appLocation: location 50 | acrUrl: common.outputs.acrUrl 51 | storageName: common.outputs.storageName 52 | vaultUri: common.outputs.vaultUri 53 | identityResourceId: common.outputs.identityResourceId 54 | identityClientId: common.outputs.identityClientId 55 | envId: acaenv.outputs.envId 56 | useSystemIdentity: useSystemIdentity 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample_native/index.bicepparam: -------------------------------------------------------------------------------- 1 | using './index.bicep' 2 | 3 | // Location to create the resources in. 4 | param location = 'centraluseuap' 5 | 6 | // Set this param to unique value to get consistent resources everytime deployed. 7 | // param prefix = '' 8 | 9 | // set these flags to true to enable Vnet, and Vnet Internal. 10 | param hasVnet = false 11 | param isVnetInternal = false 12 | 13 | // set this to true to use system assigned identity 14 | param useSystemIdentity = false 15 | -------------------------------------------------------------------------------- /samples/Biceptemplates/MI_VNET_sample_native/roleassignments.bicep: -------------------------------------------------------------------------------- 1 | 2 | param prefix string 3 | param principalId string 4 | 5 | // Role Definitions 6 | resource acrPullRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 7 | name: '7f951dda-4ed3-4680-a7ca-43fe172d538d' 8 | } 9 | 10 | resource storageBlobDataOwnerRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 11 | name: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b' 12 | } 13 | 14 | resource storageQueueDataReaderRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 15 | name: '19e7f393-937e-4f77-808e-94535e297925' 16 | } 17 | 18 | resource storageQueueProcessorRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 19 | name: '8a0f0c08-91a1-4084-bc3d-661d67233fed' 20 | } 21 | 22 | resource storageQueueContributorRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 23 | name: '974c5e8b-45b9-4653-ba55-5f855dd0fb88' 24 | } 25 | 26 | resource storageQueueSenderRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 27 | name: 'c6a89b2d-59bc-44d0-9896-0f6e12d7b80a' 28 | } 29 | 30 | resource keyVaultSecretOfficerRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 31 | name: 'b86a8fe4-44ce-4948-aee5-eccb2c155cd7' 32 | } 33 | 34 | resource keyVaultSecretUserRoleDef 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { 35 | name: '4633458b-17de-408a-b874-0445c86b69e6' 36 | } 37 | 38 | 39 | // Role Assignments 40 | resource acrPullRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 41 | name: guid(prefix, acrPullRoleDef.id) 42 | properties: { 43 | roleDefinitionId: acrPullRoleDef.id 44 | principalId: principalId 45 | principalType: 'ServicePrincipal' 46 | } 47 | } 48 | 49 | resource storageBlobDataOwnerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 50 | name: guid(prefix, storageBlobDataOwnerRoleDef.id) 51 | properties: { 52 | roleDefinitionId: storageBlobDataOwnerRoleDef.id 53 | principalId: principalId 54 | principalType: 'ServicePrincipal' 55 | } 56 | } 57 | 58 | resource storageQueueDataReaderRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 59 | name: guid(prefix, storageQueueDataReaderRoleDef.id) 60 | properties: { 61 | roleDefinitionId: storageQueueDataReaderRoleDef.id 62 | principalId: principalId 63 | principalType: 'ServicePrincipal' 64 | } 65 | } 66 | 67 | resource storageQueueProcessorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 68 | name: guid(prefix, storageQueueProcessorRoleDef.id) 69 | properties: { 70 | roleDefinitionId: storageQueueProcessorRoleDef.id 71 | principalId: principalId 72 | principalType: 'ServicePrincipal' 73 | } 74 | } 75 | 76 | resource storageQueueContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 77 | name: guid(prefix, storageQueueContributorRoleDef.id) 78 | properties: { 79 | roleDefinitionId: storageQueueContributorRoleDef.id 80 | principalId: principalId 81 | principalType: 'ServicePrincipal' 82 | } 83 | } 84 | 85 | resource storageQueueSenderignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 86 | name: guid(prefix, storageQueueSenderRoleDef.id) 87 | properties: { 88 | roleDefinitionId: storageQueueSenderRoleDef.id 89 | principalId: principalId 90 | principalType: 'ServicePrincipal' 91 | } 92 | } 93 | 94 | resource keyVaultSecretOfficerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 95 | name: guid(prefix, keyVaultSecretOfficerRoleDef.id) 96 | properties: { 97 | roleDefinitionId: keyVaultSecretOfficerRoleDef.id 98 | principalId: principalId 99 | principalType: 'ServicePrincipal' 100 | } 101 | } 102 | 103 | resource keyVaultSecretUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { 104 | name: guid(prefix, keyVaultSecretUserRoleDef.id) 105 | properties: { 106 | roleDefinitionId: keyVaultSecretUserRoleDef.id 107 | principalId: principalId 108 | principalType: 'ServicePrincipal' 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /samples/DurableFunctions/LocalFunctionProj/.dockerignore: -------------------------------------------------------------------------------- 1 | local.settings.json -------------------------------------------------------------------------------- /samples/DurableFunctions/LocalFunctionProj/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-azuretools.vscode-azurefunctions" 4 | ] 5 | } -------------------------------------------------------------------------------- /samples/DurableFunctions/LocalFunctionProj/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS installer-env 2 | 3 | COPY . /src/dotnet-function-app 4 | WORKDIR /src/dotnet-function-app 5 | RUN dotnet publish *.csproj --output /home/site/wwwroot 6 | 7 | # To enable ssh & remote debugging on app service change the base image to the one below 8 | # FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated7.0-appservice 9 | FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated7.0 10 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 11 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true 12 | 13 | COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] 14 | ENV WEBSITE_HOSTNAME="localhost:80" 15 | ENV AzureWebJobsStorage="" 16 | ENV SQLDB_Connection="" -------------------------------------------------------------------------------- /samples/DurableFunctions/LocalFunctionProj/DurableFunctionsOrchestrationCSharp.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using Microsoft.Azure.Functions.Worker; 3 | using Microsoft.Azure.Functions.Worker.Http; 4 | using Microsoft.Extensions.Logging; 5 | 6 | using Microsoft.DurableTask; 7 | using Microsoft.DurableTask.Client; 8 | 9 | using System.Threading.Tasks; 10 | using System.Collections.Generic; 11 | 12 | namespace Company.Function 13 | { 14 | public static class DurableFunctionsOrchestrationCSharp 15 | { 16 | [Function(nameof(DurableFunctionsOrchestrationCSharp))] 17 | public static async Task> RunOrchestrator( 18 | [OrchestrationTrigger] TaskOrchestrationContext context) 19 | { 20 | ILogger logger = context.CreateReplaySafeLogger(nameof(DurableFunctionsOrchestrationCSharp)); 21 | logger.LogInformation("Saying hello."); 22 | var outputs = new List(); 23 | 24 | // Replace name and input with values relevant for your Durable Functions Activity 25 | outputs.Add(await context.CallActivityAsync(nameof(SayHello), "Tokyo")); 26 | outputs.Add(await context.CallActivityAsync(nameof(SayHello), "Seattle")); 27 | outputs.Add(await context.CallActivityAsync(nameof(SayHello), "London")); 28 | 29 | // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"] 30 | return outputs; 31 | } 32 | 33 | [Function(nameof(SayHello))] 34 | public static string SayHello([ActivityTrigger] string name, FunctionContext executionContext) 35 | { 36 | ILogger logger = executionContext.GetLogger("SayHello"); 37 | logger.LogInformation("Saying hello to {name}.", name); 38 | return $"Hello {name}!"; 39 | } 40 | 41 | [Function("DurableFunctionsOrchestrationCSharp_HttpStart")] 42 | public static async Task HttpStart( 43 | [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req, 44 | [DurableClient] DurableTaskClient client, 45 | FunctionContext executionContext) 46 | { 47 | ILogger logger = executionContext.GetLogger("DurableFunctionsOrchestrationCSharp_HttpStart"); 48 | 49 | // Function input comes from the request content. 50 | string instanceId = await client.ScheduleNewOrchestrationInstanceAsync( 51 | nameof(DurableFunctionsOrchestrationCSharp)); 52 | 53 | logger.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId); 54 | 55 | // Returns an HTTP 202 response with an instance management payload. 56 | // See https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-http-api#start-orchestration 57 | return await client.CreateCheckStatusResponseAsync(req, instanceId); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /samples/DurableFunctions/LocalFunctionProj/LocalFunctionProj.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net7.0 4 | v4 5 | Exe 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | PreserveNewest 19 | 20 | 21 | PreserveNewest 22 | Never 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/DurableFunctions/LocalFunctionProj/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Hosting; 2 | 3 | var host = new HostBuilder() 4 | .ConfigureFunctionsWorkerDefaults() 5 | .Build(); 6 | 7 | host.Run(); 8 | -------------------------------------------------------------------------------- /samples/DurableFunctions/LocalFunctionProj/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "LocalFunctionProj": { 4 | "commandName": "Project", 5 | "commandLineArgs": "--port 7039", 6 | "launchBrowser": false 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /samples/DurableFunctions/LocalFunctionProj/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "extensions": { 4 | "durableTask": { 5 | "storageProvider": { 6 | "type": "mssql", 7 | "connectionStringName": "SQLDB_Connection", 8 | "createDatabaseIfNotExists": true 9 | } 10 | } 11 | }, 12 | "logging": { 13 | "logLevel": { 14 | "DurableTask.SqlServer": "Warning", 15 | "DurableTask.Core": "Warning" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /samples/DurableFunctions/media/http_start_orchestration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/DurableFunctions/media/http_start_orchestration.png -------------------------------------------------------------------------------- /samples/DurableFunctions/media/orchestration_instance_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/DurableFunctions/media/orchestration_instance_status.png -------------------------------------------------------------------------------- /samples/DurableFunctions/media/sql_connection_string_portal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/DurableFunctions/media/sql_connection_string_portal.png -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/.dockerignore: -------------------------------------------------------------------------------- 1 | local.settings.json -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/.funcignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | csx 4 | .vs 5 | edge 6 | Publish 7 | 8 | *.user 9 | *.suo 10 | *.cscfg 11 | *.Cache 12 | project.lock.json 13 | 14 | /packages 15 | /TestResults 16 | 17 | /tools/NuGet.exe 18 | /App_Data 19 | /secrets 20 | /data 21 | .secrets 22 | appsettings.json 23 | local.settings.json 24 | 25 | node_modules 26 | dist 27 | 28 | # Local python packages 29 | .python_packages/ 30 | 31 | # Python Environments 32 | .env 33 | .venv 34 | env/ 35 | venv/ 36 | ENV/ 37 | env.bak/ 38 | venv.bak/ 39 | 40 | # Byte-compiled / optimized / DLL files 41 | __pycache__/ 42 | *.py[cod] 43 | *$py.class 44 | 45 | # Azurite artifacts 46 | __blobstorage__ 47 | __queuestorage__ 48 | __azurite_db*__.json -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/Dockerfile: -------------------------------------------------------------------------------- 1 | # To enable ssh & remote debugging on app service change the base image to the one below 2 | # FROM mcr.microsoft.com/azure-functions/python:4-python3.10-appservice 3 | FROM mcr.microsoft.com/azure-functions/python:4-python3.10 4 | 5 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 6 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true \ 7 | AzureWebJobsFeatureFlags=EnableWorkerIndexing 8 | 9 | COPY requirements.txt / 10 | RUN pip install -r /requirements.txt 11 | 12 | COPY . /home/site/wwwroot -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/WrapperFunction/__init__.py: -------------------------------------------------------------------------------- 1 | import azure.functions as func 2 | 3 | import fastapi 4 | 5 | app = fastapi.FastAPI() 6 | 7 | @app.get("/sample") 8 | async def index(): 9 | return { 10 | "info": "Try /hello/ for parameterized route.", 11 | } 12 | 13 | 14 | @app.get("/hello/{name}") 15 | async def get_name(name: str): 16 | return { 17 | "name": name, 18 | } 19 | 20 | @app.get("/order/{ordername}") 21 | async def get_name(ordername: str): 22 | return { 23 | "name": ordername, 24 | } 25 | -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/function_app.py: -------------------------------------------------------------------------------- 1 | import azure.functions as func 2 | 3 | from WrapperFunction import app as fastapi_app 4 | 5 | app = func.AsgiFunctionApp(app=fastapi_app, http_auth_level=func.AuthLevel.ANONYMOUS) -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/getting_started.md: -------------------------------------------------------------------------------- 1 | ## Getting Started with Azure Function 2 | ### Last updated: March 8th 2021 3 | 4 | #### Project Structure 5 | The main project folder () can contain the following files: 6 | 7 | * **local.settings.json** - Used to store app settings and connection strings when running locally. This file doesn't get published to Azure. To learn more, see [local.settings.file](https://aka.ms/azure-functions/python/local-settings). 8 | * **requirements.txt** - Contains the list of Python packages the system installs when publishing to Azure. 9 | * **host.json** - Contains global configuration options that affect all functions in a function app. This file does get published to Azure. Not all options are supported when running locally. To learn more, see [host.json](https://aka.ms/azure-functions/python/host.json). 10 | * **.vscode/** - (Optional) Contains store VSCode configuration. To learn more, see [VSCode setting](https://aka.ms/azure-functions/python/vscode-getting-started). 11 | * **.venv/** - (Optional) Contains a Python virtual environment used by local development. 12 | * **Dockerfile** - (Optional) Used when publishing your project in a [custom container](https://aka.ms/azure-functions/python/custom-container). 13 | * **tests/** - (Optional) Contains the test cases of your function app. For more information, see [Unit Testing](https://aka.ms/azure-functions/python/unit-testing). 14 | * **.funcignore** - (Optional) Declares files that shouldn't get published to Azure. Usually, this file contains .vscode/ to ignore your editor setting, .venv/ to ignore local Python virtual environment, tests/ to ignore test cases, and local.settings.json to prevent local app settings being published. 15 | 16 | Each function has its own code file and binding configuration file ([**function.json**](https://aka.ms/azure-functions/python/function.json)). 17 | 18 | #### Developing your first Python function using VS Code 19 | 20 | If you have not already, please checkout our [quickstart](https://aka.ms/azure-functions/python/quickstart) to get you started with Azure Functions developments in Python. 21 | 22 | #### Publishing your function app to Azure 23 | 24 | For more information on deployment options for Azure Functions, please visit this [guide](https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python#publish-the-project-to-azure). 25 | 26 | #### Next Steps 27 | 28 | * To learn more about developing Azure Functions, please visit [Azure Functions Developer Guide](https://aka.ms/azure-functions/python/developer-guide). 29 | 30 | * To learn more specific guidance on developing Azure Functions with Python, please visit [Azure Functions Developer Python Guide](https://aka.ms/azure-functions/python/python-developer-guide). -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | } 11 | , 12 | "extensionBundle": { 13 | "id": "Microsoft.Azure.Functions.ExtensionBundle", 14 | "version": "[3.*, 4.0.0)" 15 | }, 16 | "extensions": 17 | { 18 | "http": 19 | { 20 | "routePrefix": "" 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "", 5 | "FUNCTIONS_WORKER_RUNTIME": "python", 6 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" 7 | } 8 | } -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/requirements.txt: -------------------------------------------------------------------------------- 1 | # Do not include azure-functions-worker in this file 2 | # The Python Worker is managed by the Azure Functions platform 3 | # Manually managing azure-functions-worker may cause unexpected issues 4 | 5 | azure-functions>=1.12.0 6 | fastapi -------------------------------------------------------------------------------- /samples/FastAPIHttpTrigger/workflows/azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # This pipeline will build a container and deploy it to an Azure Functions App on Linux. 2 | # 3 | # This pipeline assumes you have already created the target Azure Functions app on Azure. 4 | # 5 | # To configure this pipeline: 6 | # Replace the following with correct values in this pipeline: 7 | # - your-registry 8 | # - your-namespace 9 | # - your-image-name 10 | # - your-subscription-id 11 | # - your-functionapp-name 12 | # 13 | # For more information on yaml pipelines: https://aka.ms/yaml 14 | 15 | trigger: 16 | - main 17 | 18 | pool: 19 | name: Azure Pipelines 20 | 21 | steps: 22 | - task: Docker@2 23 | displayName: Login 24 | inputs: 25 | containerRegistry: docker.io 26 | command: login 27 | 28 | - task: Docker@2 29 | displayName: build 30 | inputs: 31 | containerRegistry: docker.io 32 | repository: 'ramyaliftrdocker/funcpythonimage' 33 | command: build 34 | 35 | - task: Docker@2 36 | displayName: push 37 | inputs: 38 | containerRegistry: docker.io 39 | repository: 'ramyaliftrdocker/funcpythonimage' 40 | command: push 41 | 42 | - task: AzureFunctionAppContainer@1 43 | displayName: 'Azure Function App on Container Deploy' 44 | inputs: 45 | azureSubscription: 'azureSubscription' 46 | appName: 'fastapihttpfuncaca' 47 | imageName: 'ramyaliftrdocker/funcpythonimage:$(Build.BuildId)' 48 | -------------------------------------------------------------------------------- /samples/FunctionGHProj/.dockerignore: -------------------------------------------------------------------------------- 1 | local.settings.json -------------------------------------------------------------------------------- /samples/FunctionGHProj/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-azuretools.vscode-azurefunctions" 4 | ] 5 | } -------------------------------------------------------------------------------- /samples/FunctionGHProj/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:7.0 AS installer-env 2 | 3 | # Build requires 3.1 SDK 4 | COPY --from=mcr.microsoft.com/dotnet/core/sdk:3.1 /usr/share/dotnet /usr/share/dotnet 5 | 6 | COPY . /src/dotnet-function-app 7 | RUN cd /src/dotnet-function-app && \ 8 | mkdir -p /home/site/wwwroot && \ 9 | dotnet publish *.csproj --output /home/site/wwwroot 10 | 11 | # To enable ssh & remote debugging on app service change the base image to the one below 12 | # FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0-appservice 13 | FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated7.0 14 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 15 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true 16 | 17 | COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] -------------------------------------------------------------------------------- /samples/FunctionGHProj/FunctionGHProj.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net7.0 4 | v4 5 | Exe 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | PreserveNewest 17 | 18 | 19 | PreserveNewest 20 | Never 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/FunctionGHProj/HttpGHExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Net; 3 | using Microsoft.Azure.Functions.Worker; 4 | using Microsoft.Azure.Functions.Worker.Http; 5 | using Microsoft.Extensions.Logging; 6 | 7 | namespace FunctionGHProj 8 | { 9 | public class HttpGHExample 10 | { 11 | private readonly ILogger _logger; 12 | 13 | public HttpGHExample(ILoggerFactory loggerFactory) 14 | { 15 | _logger = loggerFactory.CreateLogger(); 16 | } 17 | 18 | [Function("HttpGHExample")] 19 | public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req) 20 | { 21 | _logger.LogInformation("C# HTTP trigger function processed a request."); 22 | 23 | var response = req.CreateResponse(HttpStatusCode.OK); 24 | response.Headers.Add("Content-Type", "text/plain; charset=utf-8"); 25 | 26 | response.WriteString("Welcome to Azure Functions!"); 27 | 28 | return response; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/FunctionGHProj/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Hosting; 2 | 3 | var host = new HostBuilder() 4 | .ConfigureFunctionsWorkerDefaults() 5 | .Build(); 6 | 7 | host.Run(); -------------------------------------------------------------------------------- /samples/FunctionGHProj/Readme.md: -------------------------------------------------------------------------------- 1 | Use [GitHub Actions](https://github.com/features/actions) to define a workflow to automatically build and deploy code to your function app in Azure Functions. 2 | 3 | In GitHub Actions, a [workflow](https://docs.github.com/en/actions/learn-github-actions/introduction-to-github-actions#the-components-of-github-actions) is an automated process that you define in your GitHub repository. This process tells GitHub how to build and deploy your function app project on GitHub. 4 | 5 | A workflow is defined by a YAML (.yml) file in the /.github/workflows/ path in your repository. This definition contains the various steps and parameters that make up the workflow. 6 | 7 | For an Azure Functions workflow, the file has three sections: 8 | 9 | -------------------------------------------------------------------------------- /samples/FunctionGHProj/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/.dockerignore: -------------------------------------------------------------------------------- 1 | local.settings.json -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS installer-env 2 | 3 | 4 | 5 | COPY . /src/dotnet-function-app 6 | RUN cd /src/dotnet-function-app && \ 7 | mkdir -p /home/site/wwwroot && \ 8 | dotnet publish *.csproj --output /home/site/wwwroot 9 | 10 | # To enable ssh & remote debugging on app service change the base image to the one below 11 | # FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0-appservice 12 | FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated7.0 13 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 14 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true 15 | 16 | COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] 17 | -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Hosting; 2 | 3 | var host = new HostBuilder() 4 | .ConfigureFunctionsWorkerDefaults() 5 | .Build(); 6 | 7 | host.Run(); -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/ServiceBusExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Azure.Functions.Worker; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace ServiceBusProj 6 | { 7 | public class ServiceBusExample 8 | { 9 | private readonly ILogger _logger; 10 | 11 | public ServiceBusExample(ILoggerFactory loggerFactory) 12 | { 13 | _logger = loggerFactory.CreateLogger(); 14 | } 15 | 16 | [Function("ServiceBusExample")] 17 | public void Run([ServiceBusTrigger("upper-case", Connection = "AzureWebJobsServiceBus")] string myQueueItem) 18 | { 19 | _logger.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/ServiceBusProj.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net7.0 4 | v4 5 | Exe 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | PreserveNewest 17 | 18 | 19 | PreserveNewest 20 | Never 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/github_actions_workflow.yml: -------------------------------------------------------------------------------- 1 | #This workflow will build a container image and deploy it to an Azure Functions App when a commit is pushed to your default branch. 2 | # 3 | # This workflow assumes you have already created the target Azure Functions app. 4 | # 5 | # To configure this workflow: 6 | # 1. Set up the following secrets in your repository: 7 | # - AZURE_RBAC_CREDENTIALS 8 | # - REGISTRY_USERNAME 9 | # - REGISTRY_PASSWORD 10 | # 2. Change env variables for your configuration. 11 | # 12 | # For more information on: 13 | # - GitHub Actions for Azure: https://github.com/Azure/Actions 14 | # - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential 15 | # 16 | # For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp 17 | 18 | name: Deployment for cp-centauri-site 19 | 20 | on: 21 | push: 22 | branches: 23 | [ main ] 24 | 25 | permissions: 26 | contents: read 27 | 28 | env: 29 | AZURE_FUNCTION_APP_NAME: # set this to your function app name on Azure 30 | AZURE_RESOURCE_GROUP_NAME: # set this to your resource group name on Azure 31 | LOGIN_SERVER: # set this to login server for your private container registry (e.g. 'contoso.azurecr.io', 'docker.io' ) 32 | NAMESPACE: # set this to proper value for NAMESPACE 33 | IMAGE: # set this to proper value for IMAGE 34 | TAG: # set this to proper value for TAG 35 | 36 | jobs: 37 | build: 38 | runs-on: ubuntu-latest 39 | 40 | steps: 41 | - name: Checkout to the branch 42 | uses: actions/checkout@v2 43 | 44 | - name: Set up Docker Buildx 45 | uses: docker/setup-buildx-action@v1 46 | 47 | - name: Log in to container registry 48 | uses: docker/login-action@v1 49 | with: 50 | registry: ${{ env.LOGIN_SERVER }} 51 | username: ${{ secrets.REGISTRY_USERNAME }} 52 | password: ${{ secrets.REGISTRY_PASSWORD }} 53 | 54 | - name: Build and push container image to registry 55 | uses: docker/build-push-action@v2 56 | with: 57 | push: true 58 | tags: ${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }} 59 | # file: ./Dockerfile 60 | context: ./ 61 | 62 | 63 | deploy: 64 | runs-on: ubuntu-latest 65 | needs: build 66 | 67 | steps: 68 | - name: Azure Login 69 | uses: azure/login@v1 70 | with: 71 | creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} 72 | 73 | - name: Deploy to functionapp 74 | uses: azure/CLI@v1 75 | with: 76 | azcliversion: 2.47.0 77 | inlineScript: | 78 | az config set extension.use_dynamic_install=yes_without_prompt 79 | az functionapp config container set -n ${{ env.AZURE_FUNCTION_APP_NAME }} -g ${{ env.AZURE_RESOURCE_GROUP_NAME }} --image ${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }} --registry-server ${{ env.LOGIN_SERVER }} --registry-username ${{ secrets.REGISTRY_USERNAME }} --registry-password ${{ secrets.REGISTRY_PASSWORD }} 80 | - name: Azure logout 81 | run: | 82 | az logout 83 | 84 | -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 5 | "AzureWebJobsServiceBus":<> 6 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /samples/FunctionandSpringAppSample/servicebuscale.js: -------------------------------------------------------------------------------- 1 | const { ServiceBusClient } = require("@azure/service-bus"); 2 | 3 | // connection string to your Service Bus namespace 4 | const connectionString =<> 5 | 6 | 7 | // name of the queue 8 | const queueName = "lower-case" 9 | 10 | 11 | 12 | async function main() { 13 | const sbClient = new ServiceBusClient(connectionString); 14 | 15 | // createSender() can also be used to create a sender for a topic. 16 | const sender = sbClient.createSender(queueName); 17 | 18 | try { 19 | for(let n=0; n < 100; n++) 20 | { 21 | console.log(`Sending scientists`); 22 | const message = { 23 | contentType: "application/json", 24 | subject: "Scientist", 25 | body: { firstName: "convert albert to uppercase", lastName: "convert einstein to uppercase" }, 26 | timeToLive: 1 * 60 * 1000, // message expires in 2 minutes 27 | }; 28 | await sender.sendMessages(message); 29 | } 30 | 31 | // Close the sender 32 | console.log(`Done sending, closing...`); 33 | await sender.close(); 34 | } 35 | finally { 36 | await sbClient.close(); 37 | } 38 | } 39 | 40 | 41 | // call the main function 42 | main().catch((err) => { 43 | console.log("Error occurred: ", err); 44 | process.exit(1); 45 | }); 46 | -------------------------------------------------------------------------------- /samples/GitHubActions/Func_on_ACA_GitHubAction_deployment.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a container and deploy it to an Azure Functions App on Linux when a commit is pushed to your default branch. 2 | # 3 | # This workflow assumes you have already created the target Azure Functions app on Azure. 4 | # 5 | # To configure this workflow: 6 | # 1. Set up the following secrets in your repository: 7 | # - AZURE_RBAC_CREDENTIALS 8 | # - REGISTRY_USERNAME 9 | # - REGISTRY_PASSWORD 10 | # 2. Change env variables for your configuration. 11 | # 3. Add this yaml file to your project's .github/workflows/ 12 | # 4. Push your local project to your GitHub Repository 13 | # 14 | # For more information on: 15 | # - GitHub Actions for Azure: https://github.com/Azure/Actions 16 | # - Azure Functions Container Action: https://github.com/Azure/functions-container-action 17 | # - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential 18 | # 19 | # For more information on GitHub Actions: https://help.github.com/en/categories/automating-your-workflow-with-github-actions 20 | 21 | name: Deploy container to Azure Functions App 22 | 23 | on: 24 | # Automatically trigger it when detected changes in repo 25 | push: 26 | branches: [ main ] 27 | 28 | permissions: 29 | contents: read 30 | 31 | env: 32 | AZURE_FUNCTION_APP_NAME: 'your-app-name' # set this to your function app name on Azure 33 | LOGIN_SERVER: 'login-server' # set this to login server for your private container registry (e.g. 'contoso.azurecr.io', 'docker.io' ) 34 | REGISTRY: 'your-registry' # set this to proper value for REGISTRY 35 | NAMESPACE: 'your-namespace' # set this to proper value for NAMESPACE 36 | IMAGE: 'your-image' # set this to proper value for IMAGE 37 | TAG: ${{ github.sha }} # set this to proper value for TAG 38 | 39 | jobs: 40 | build: 41 | runs-on: ubuntu-latest 42 | 43 | steps: 44 | - name: Checkout to the branch 45 | uses: actions/checkout@v3 46 | 47 | - name: Set up Docker Buildx 48 | uses: docker/setup-buildx-action@v1 49 | 50 | - name: Log in to container registry 51 | uses: docker/login-action@v1 52 | with: 53 | registry: ${{ env.LOGIN_SERVER }} 54 | username: ${{ secrets.REGISTRY_USERNAME }} 55 | password: ${{ secrets.REGISTRY_PASSWORD }} 56 | 57 | - name: Build and push container image to registry 58 | uses: docker/build-push-action@v2 59 | with: 60 | push: true 61 | tags: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }} 62 | file: ./Dockerfile 63 | context: ./ 64 | 65 | 66 | deploy: 67 | runs-on: ubuntu-latest 68 | needs: build 69 | 70 | steps: 71 | - name: Azure Login 72 | uses: azure/login@v1 73 | with: 74 | creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} 75 | 76 | - name: 'Run Azure Functions Container Action' 77 | uses: Azure/functions-container-action@v1 78 | id: fa 79 | with: 80 | app-name: ${{ env.AZURE_FUNCTION_APP_NAME }} 81 | image: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }} 82 | 83 | # If you want to display or use the functionapp url, then uncomment the task below 84 | #- name: 'Published functionapp url' 85 | # run: | 86 | # echo "${{ steps.fa.outputs.app-url }}" 87 | 88 | - name: Azure logout 89 | run: | 90 | az logout 91 | -------------------------------------------------------------------------------- /samples/GitHubActions/Readme.md: -------------------------------------------------------------------------------- 1 | # Deploy container to Azure Functions App using GitHub workflow 2 | This workflow will build a container and deploy it to an Azure Functions App on Linux when a commit is pushed to your default branch. 3 | 4 | ## Pre-requisite 5 | This workflow assumes you have already created the target Azure Functions app on Azure. 6 | 7 | ## To configure this workflow: 8 | 1. Set up the following secrets in your repository: 9 | - AZURE_RBAC_CREDENTIALS 10 | - REGISTRY_USERNAME 11 | - REGISTRY_PASSWORD 12 | 2. Change env variables for your configuration. 13 | 3. Add this yaml file to your project's .github/workflows/ 14 | 4. Push your local project to your GitHub Repository 15 | 16 | ## For more information on: 17 | - GitHub Actions for Azure: https://github.com/Azure/Actions 18 | - Azure Functions Container Action: https://github.com/Azure/functions-container-action 19 | - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential 20 | 21 | ## For more information on GitHub Actions: 22 | https://help.github.com/en/categories/automating-your-workflow-with-github-actions 23 | -------------------------------------------------------------------------------- /samples/Java Samples/Readme.md: -------------------------------------------------------------------------------- 1 | # **Build & Run** 2 | 3 | To build the docker image, execute docker build command as you would for any other docker based project 4 | 5 | `docker build -t .` 6 | 7 | This builds up the auto-generated function code along with Azure Functions runtime which can then be run using 8 | 9 | `docker run -p 8080:80 ` 10 | 11 | Now you can go to http://localhost:8080/ in your browser and see your function running. 12 | -------------------------------------------------------------------------------- /samples/Java Samples/httptrigger/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG JAVA_VERSION=8 2 | # This image additionally contains function core tools – useful when using custom extensions 3 | #FROM mcr.microsoft.com/azure-functions/java:4-java$JAVA_VERSION-core-tools AS installer-env 4 | FROM mcr.microsoft.com/azure-functions/java:4-java$JAVA_VERSION-build AS installer-env 5 | 6 | COPY . /src/java-function-app 7 | RUN cd /src/java-function-app && \ 8 | mkdir -p /home/site/wwwroot && \ 9 | mvn clean package && \ 10 | cd ./target/azure-functions/ && \ 11 | cd $(ls -d */|head -n 1) && \ 12 | cp -a . /home/site/wwwroot 13 | 14 | # This image is ssh enabled 15 | FROM mcr.microsoft.com/azure-functions/java:4-java$JAVA_VERSION-appservice 16 | # This image isn't ssh enabled 17 | #FROM mcr.microsoft.com/azure-functions/java:4-java$JAVA_VERSION 18 | 19 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 20 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true 21 | 22 | COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] -------------------------------------------------------------------------------- /samples/Java Samples/httptrigger/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "extensionBundle": { 4 | "id": "Microsoft.Azure.Functions.ExtensionBundle", 5 | "version": "[3.*, 4.0.0)" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /samples/Java Samples/httptrigger/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "", 5 | "FUNCTIONS_WORKER_RUNTIME": "java" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /samples/Java Samples/httptrigger/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | microsoft 6 | microsoft 7 | microsoft 8 | jar 9 | 10 | Azure Java Functions 11 | 12 | 13 | UTF-8 14 | 1.8 15 | 1.24.0 16 | 2.2.0 17 | microsoft-20230502162336759 18 | 19 | 20 | 21 | 22 | com.microsoft.azure.functions 23 | azure-functions-java-library 24 | ${azure.functions.java.library.version} 25 | 26 | 27 | 28 | org.junit.jupiter 29 | junit-jupiter 30 | 5.4.2 31 | test 32 | 33 | 34 | 35 | org.mockito 36 | mockito-core 37 | 2.23.4 38 | test 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.plugins 46 | maven-compiler-plugin 47 | 3.8.1 48 | 49 | ${java.version} 50 | ${java.version} 51 | ${project.build.sourceEncoding} 52 | 53 | 54 | 55 | com.microsoft.azure 56 | azure-functions-maven-plugin 57 | ${azure.functions.maven.plugin.version} 58 | 59 | 60 | ${functionAppName} 61 | 62 | java-functions-group 63 | 64 | java-functions-app-service-plan 65 | 66 | 67 | westus 68 | 69 | 70 | EP1 71 | 72 | 73 | 74 | 75 | docker 76 | [hub-user/]repo-name[:tag] 77 | 78 | 79 | 80 | 81 | 82 | FUNCTIONS_EXTENSION_VERSION 83 | ~4 84 | 85 | 86 | 87 | 88 | 89 | package-functions 90 | 91 | package 92 | 93 | 94 | 95 | 96 | 97 | 98 | maven-clean-plugin 99 | 3.1.0 100 | 101 | 102 | 103 | obj 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /samples/Java Samples/httptrigger/src/main/java/com/microsoft/Function.java: -------------------------------------------------------------------------------- 1 | package com.microsoft; 2 | 3 | import com.microsoft.azure.functions.ExecutionContext; 4 | import com.microsoft.azure.functions.HttpMethod; 5 | import com.microsoft.azure.functions.HttpRequestMessage; 6 | import com.microsoft.azure.functions.HttpResponseMessage; 7 | import com.microsoft.azure.functions.HttpStatus; 8 | import com.microsoft.azure.functions.annotation.AuthorizationLevel; 9 | import com.microsoft.azure.functions.annotation.FunctionName; 10 | import com.microsoft.azure.functions.annotation.HttpTrigger; 11 | 12 | import java.util.Optional; 13 | 14 | /** 15 | * Azure Functions with HTTP Trigger. 16 | */ 17 | public class Function { 18 | /** 19 | * This function listens at endpoint "/api/HttpExample". Two ways to invoke it using "curl" command in bash: 20 | * 1. curl -d "HTTP Body" {your host}/api/HttpExample 21 | * 2. curl "{your host}/api/HttpExample?name=HTTP%20Query" 22 | */ 23 | @FunctionName("HttpExample") 24 | public HttpResponseMessage run( 25 | @HttpTrigger( 26 | name = "req", 27 | methods = {HttpMethod.GET, HttpMethod.POST}, 28 | authLevel = AuthorizationLevel.ANONYMOUS) 29 | HttpRequestMessage> request, 30 | final ExecutionContext context) { 31 | context.getLogger().info("Java HTTP trigger processed a request."); 32 | 33 | // Parse query parameter 34 | final String query = request.getQueryParameters().get("name"); 35 | final String name = request.getBody().orElse(query); 36 | 37 | if (name == null) { 38 | return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please pass a name on the query string or in the request body").build(); 39 | } else { 40 | return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /samples/Java Samples/httptrigger/src/test/java/com/microsoft/FunctionTest.java: -------------------------------------------------------------------------------- 1 | package com.microsoft; 2 | 3 | import com.microsoft.azure.functions.*; 4 | import org.mockito.invocation.InvocationOnMock; 5 | import org.mockito.stubbing.Answer; 6 | 7 | import java.util.*; 8 | import java.util.logging.Logger; 9 | 10 | import org.junit.jupiter.api.Test; 11 | import static org.junit.jupiter.api.Assertions.*; 12 | import static org.mockito.ArgumentMatchers.*; 13 | import static org.mockito.Mockito.*; 14 | 15 | 16 | /** 17 | * Unit test for Function class. 18 | */ 19 | public class FunctionTest { 20 | /** 21 | * Unit test for HttpTriggerJava method. 22 | */ 23 | @Test 24 | public void testHttpTriggerJava() throws Exception { 25 | // Setup 26 | @SuppressWarnings("unchecked") 27 | final HttpRequestMessage> req = mock(HttpRequestMessage.class); 28 | 29 | final Map queryParams = new HashMap<>(); 30 | queryParams.put("name", "Azure"); 31 | doReturn(queryParams).when(req).getQueryParameters(); 32 | 33 | final Optional queryBody = Optional.empty(); 34 | doReturn(queryBody).when(req).getBody(); 35 | 36 | doAnswer(new Answer() { 37 | @Override 38 | public HttpResponseMessage.Builder answer(InvocationOnMock invocation) { 39 | HttpStatus status = (HttpStatus) invocation.getArguments()[0]; 40 | return new HttpResponseMessageMock.HttpResponseMessageBuilderMock().status(status); 41 | } 42 | }).when(req).createResponseBuilder(any(HttpStatus.class)); 43 | 44 | final ExecutionContext context = mock(ExecutionContext.class); 45 | doReturn(Logger.getGlobal()).when(context).getLogger(); 46 | 47 | // Invoke 48 | final HttpResponseMessage ret = new Function().run(req, context); 49 | 50 | // Verify 51 | assertEquals(ret.getStatus(), HttpStatus.OK); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /samples/Java Samples/httptrigger/src/test/java/com/microsoft/HttpResponseMessageMock.java: -------------------------------------------------------------------------------- 1 | package com.microsoft; 2 | 3 | import com.microsoft.azure.functions.*; 4 | 5 | import java.util.Map; 6 | import java.util.HashMap; 7 | 8 | /** 9 | * The mock for HttpResponseMessage, can be used in unit tests to verify if the 10 | * returned response by HTTP trigger function is correct or not. 11 | */ 12 | public class HttpResponseMessageMock implements HttpResponseMessage { 13 | private int httpStatusCode; 14 | private HttpStatusType httpStatus; 15 | private Object body; 16 | private Map headers; 17 | 18 | public HttpResponseMessageMock(HttpStatusType status, Map headers, Object body) { 19 | this.httpStatus = status; 20 | this.httpStatusCode = status.value(); 21 | this.headers = headers; 22 | this.body = body; 23 | } 24 | 25 | @Override 26 | public HttpStatusType getStatus() { 27 | return this.httpStatus; 28 | } 29 | 30 | @Override 31 | public int getStatusCode() { 32 | return httpStatusCode; 33 | } 34 | 35 | @Override 36 | public String getHeader(String key) { 37 | return this.headers.get(key); 38 | } 39 | 40 | @Override 41 | public Object getBody() { 42 | return this.body; 43 | } 44 | 45 | public static class HttpResponseMessageBuilderMock implements HttpResponseMessage.Builder { 46 | private Object body; 47 | private int httpStatusCode; 48 | private Map headers = new HashMap<>(); 49 | private HttpStatusType httpStatus; 50 | 51 | public Builder status(HttpStatus status) { 52 | this.httpStatusCode = status.value(); 53 | this.httpStatus = status; 54 | return this; 55 | } 56 | 57 | @Override 58 | public Builder status(HttpStatusType httpStatusType) { 59 | this.httpStatusCode = httpStatusType.value(); 60 | this.httpStatus = httpStatusType; 61 | return this; 62 | } 63 | 64 | @Override 65 | public HttpResponseMessage.Builder header(String key, String value) { 66 | this.headers.put(key, value); 67 | return this; 68 | } 69 | 70 | @Override 71 | public HttpResponseMessage.Builder body(Object body) { 72 | this.body = body; 73 | return this; 74 | } 75 | 76 | @Override 77 | public HttpResponseMessage build() { 78 | return new HttpResponseMessageMock(this.httpStatus, this.headers, this.body); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /samples/Kafka Sample/.dockerignore: -------------------------------------------------------------------------------- 1 | local.settings.json -------------------------------------------------------------------------------- /samples/Kafka Sample/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | csx 4 | .vs 5 | edge 6 | Publish 7 | 8 | *.user 9 | *.suo 10 | *.cscfg 11 | *.Cache 12 | project.lock.json 13 | 14 | /packages 15 | /TestResults 16 | 17 | /tools/NuGet.exe 18 | /App_Data 19 | /secrets 20 | /data 21 | .secrets 22 | appsettings.json 23 | local.settings.json 24 | 25 | node_modules 26 | dist 27 | 28 | # Local python packages 29 | .python_packages/ 30 | 31 | # Python Environments 32 | .env 33 | .venv 34 | env/ 35 | venv/ 36 | ENV/ 37 | env.bak/ 38 | venv.bak/ 39 | 40 | # Byte-compiled / optimized / DLL files 41 | __pycache__/ 42 | *.py[cod] 43 | *$py.class 44 | 45 | # Azurite artifacts 46 | __blobstorage__ 47 | __queuestorage__ 48 | __azurite_db*__.json -------------------------------------------------------------------------------- /samples/Kafka Sample/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-azuretools.vscode-azurefunctions" 4 | ] 5 | } -------------------------------------------------------------------------------- /samples/Kafka Sample/Dockerfile: -------------------------------------------------------------------------------- 1 | # To enable ssh & remote debugging on app service change the base image to the one below 2 | # FROM mcr.microsoft.com/azure-functions/python:4-python3.8-appservice 3 | FROM mcr.microsoft.com/azure-functions/python:4-python3.8 4 | 5 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 6 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true 7 | 8 | COPY requirements.txt / 9 | RUN pip install -r /requirements.txt 10 | 11 | COPY . /home/site/wwwroot -------------------------------------------------------------------------------- /samples/Kafka Sample/KafkaExample/__init__.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from azure.functions import KafkaEvent 3 | 4 | def main(kevent : KafkaEvent): 5 | logging.info(kevent.get_body().decode('utf-8')) 6 | logging.info(kevent.metadata) 7 | -------------------------------------------------------------------------------- /samples/Kafka Sample/KafkaExample/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "scriptFile": "__init__.py", 3 | "bindings": [ 4 | { 5 | "type": "kafkaTrigger", 6 | "name": "kevent", 7 | "direction": "in", 8 | "brokerList": "BrokerList", 9 | "topic": "topic", 10 | "username": "$ConnectionString", 11 | "password": "%KafkaPassword%", 12 | "protocol": "saslSsl", 13 | "authenticationMode": "plain", 14 | "consumerGroup": "$Default" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /samples/Kafka Sample/KafkaExample/readme.md: -------------------------------------------------------------------------------- 1 | # KafkaTrigger - Python 2 | 3 | The `KafkaTrigger` makes it incredibly easy to react to new events from a Kafka Broker. This sample demonstrates a simple use case of processing data from a given Kafka Broker using Python. 4 | 5 | ## How it works 6 | 7 | For a `KafkaTrigger` to work, you must provide a topic name which dictates where the messages should be read from with authentication. 8 | 9 | ## Configuration 10 | 11 | ### EventHubs for Kafka 12 | 13 | Add `BrokerList` and `KafkaPassword` to your `local.settings.json` 14 | 15 | _local.settings.json_ 16 | 17 | ```json 18 | { 19 | "IsEncrypted": false, 20 | "Values": { 21 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 22 | "FUNCTIONS_WORKER_RUNTIME": "python", 23 | "BrokerList": "{YOUR_EVENT_HUBS_NAMESPACE}.servicebus.windows.net:9093", 24 | "KafkaPassword": "{EVENT_HUBS_CONNECTION_STRING}" 25 | } 26 | } 27 | ``` 28 | 29 | ### Others 30 | 31 | Modify `function.json` or `KafkaTrigger` attribute according to your broker. -------------------------------------------------------------------------------- /samples/Kafka Sample/Readme.md: -------------------------------------------------------------------------------- 1 | # Developers guide for Kafka Functions for Python 2 | 3 | Explain how to configure and run the sample. 4 | 5 | ## Prerequisite 6 | 7 | If you want to run the sample on Windows, OSX, or Linux, you need to following tools. 8 | 9 | * [Azure Function Core Tools](https://github.com/Azure/azure-functions-core-tools) (v3 or above) 10 | * [Python 3.8](https://www.python.org/downloads/release/python-381/) 11 | * [AzureCLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) 12 | 13 | ### Start Virtual Env 14 | 15 | ```bash 16 | $ python -m venv .venv 17 | $ source .venv/bin/activate 18 | ``` 19 | 20 | ### Install Azure Functions Library 21 | 22 | ```bash 23 | $ pip install -r requirements.txt 24 | ``` 25 | 26 | ## Configuration 27 | 28 | ### EventHubs for Kafka 29 | 30 | Add `BrokerList` and `KafkaPassword` to your `local.settings.json` 31 | 32 | _local.settings.json_ 33 | 34 | ```json 35 | { 36 | "IsEncrypted": false, 37 | "Values": { 38 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 39 | "FUNCTIONS_WORKER_RUNTIME": "python", 40 | "BrokerList": "{YOUR_EVENT_HUBS_NAMESPACE}.servicebus.windows.net:9093", 41 | "KafkaPassword": "{EVENT_HUBS_CONNECTION_STRING}" 42 | } 43 | } 44 | ``` 45 | 46 | ### Others 47 | 48 | Modify `function.json` or `KafkaTrigger` attribute according to your broker. 49 | ## Run the Azure Functions 50 | 51 | ## Run 52 | 53 | To test the function locally, run the following command: 54 | 55 | ```bash 56 | $ func start 57 | ``` 58 | 59 | ### Deploy Function App 60 | 61 | Deploy the Function App as mentioned in the [README](../../README.md) 62 | 63 | #### Configure AppSettings 64 | You need to configure these application settings. `BrokerList`, `KafkaPassword` to the Function App as required for the sample. Refer to [README](../../README.md) 65 | for more details. 66 | 67 | # Resource 68 | 69 | * [Quickstart: Create a function in Azure using Visual Studio Code](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code?pivots=programming-language-python) 70 | 71 | -------------------------------------------------------------------------------- /samples/Kafka Sample/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | }, 11 | "extensionBundle": { 12 | "id": "Microsoft.Azure.Functions.ExtensionBundle", 13 | "version": "[3.*, 4.0.0)" 14 | } 15 | } -------------------------------------------------------------------------------- /samples/Kafka Sample/requirements.txt: -------------------------------------------------------------------------------- 1 | # Do not include azure-functions-worker as it may conflict with the Azure Functions platform 2 | 3 | azure-functions -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS installer-env 2 | # use following command to build linux amd on any platform 3 | # `docker build --platform linux/amd64 -t azure/functions:amd64 .` 4 | 5 | COPY . /src/dotnet-function-app 6 | WORKDIR /src/dotnet-function-app 7 | RUN dotnet publish *.csproj --output /home/site/wwwroot 8 | 9 | # To enable ssh & remote debugging on app service change the base image to the one below 10 | # FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0-appservice 11 | FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated7.0 12 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 13 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true 14 | 15 | COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] 16 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Hosting; 2 | 3 | var host = new HostBuilder() 4 | .ConfigureFunctionsWorkerDefaults() 5 | .Build(); 6 | 7 | host.Run(); -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/README.md: -------------------------------------------------------------------------------- 1 | # funcservicebus 2 | Refer to the below yml file for github actions sample yml file 3 | azure-functions-on-container-apps/samples/ServiceBus_GitHubActionSample/workflows/main.yml 4 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/ServiceBusExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Azure.Functions.Worker; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace ServiceBusProj 6 | { 7 | public class ServiceBusExample 8 | { 9 | private readonly ILogger _logger; 10 | 11 | public ServiceBusExample(ILoggerFactory loggerFactory) 12 | { 13 | _logger = loggerFactory.CreateLogger(); 14 | } 15 | 16 | [Function("ServiceBusExample")] 17 | public void Run([ServiceBusTrigger("upper-case", Connection = "AzureWebJobsServiceBus")] string myQueueItem) 18 | { 19 | _logger.LogInformation($"C# ServiceBus queue trigger function processed message new text: {myQueueItem}"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/ServiceBusProj.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net7.0 4 | v4 5 | Exe 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | PreserveNewest 17 | 18 | 19 | PreserveNewest 20 | Never 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Azure.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Azure.Core.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Google.Protobuf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Google.Protobuf.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Grpc.Core.Api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Grpc.Core.Api.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Grpc.Net.Client.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Grpc.Net.Client.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Grpc.Net.ClientFactory.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Grpc.Net.ClientFactory.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Grpc.Net.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Grpc.Net.Common.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.Core.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.Extensions.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.Extensions.Abstractions.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.Extensions.ServiceBus.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.Extensions.ServiceBus.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.Grpc.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.Grpc.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Azure.Functions.Worker.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Bcl.AsyncInterfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Bcl.AsyncInterfaces.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.CodeAnalysis.CSharp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.CodeAnalysis.CSharp.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.CodeAnalysis.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.CodeAnalysis.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.Abstractions.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.Binder.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.Binder.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.CommandLine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.CommandLine.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.EnvironmentVariables.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.EnvironmentVariables.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.FileExtensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.FileExtensions.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.Json.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.UserSecrets.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.UserSecrets.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Configuration.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.DependencyInjection.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.DependencyInjection.Abstractions.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.DependencyInjection.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.DependencyInjection.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.FileProviders.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.FileProviders.Abstractions.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.FileProviders.Physical.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.FileProviders.Physical.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.FileSystemGlobbing.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.FileSystemGlobbing.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Hosting.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Hosting.Abstractions.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Hosting.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Hosting.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Http.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Http.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.Abstractions.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.Configuration.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.Configuration.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.Console.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.Console.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.Debug.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.Debug.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.EventLog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.EventLog.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.EventSource.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.EventSource.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Logging.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Options.ConfigurationExtensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Options.ConfigurationExtensions.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Options.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Options.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Primitives.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/Microsoft.Extensions.Primitives.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ServiceBusProj.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ServiceBusProj.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ServiceBusProj.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ServiceBusProj.exe -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ServiceBusProj.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ServiceBusProj.pdb -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ServiceBusProj.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "net7.0", 4 | "framework": { 5 | "name": "Microsoft.NETCore.App", 6 | "version": "7.0.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/System.Diagnostics.EventLog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/System.Diagnostics.EventLog.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/System.Memory.Data.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/System.Memory.Data.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/cs/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/cs/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/cs/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/cs/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/de/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/de/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/de/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/de/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/es/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/es/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/es/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/es/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": [ 3 | { 4 | "name": "Startup", 5 | "typeName": "Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader.Startup, Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=551316b6919f366c", 6 | "hintPath": "./.azurefunctions/Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader.dll" 7 | }, 8 | { 9 | "name": "ServiceBus", 10 | "typeName": "Microsoft.Azure.WebJobs.ServiceBus.ServiceBusWebJobsStartup, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", 11 | "hintPath": "./.azurefunctions/Microsoft.Azure.WebJobs.ServiceBus.dll" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/fr/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/fr/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/fr/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/fr/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/functions.metadata: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "ServiceBusExample", 4 | "scriptFile": "ServiceBusProj.dll", 5 | "entryPoint": "ServiceBusProj.ServiceBusExample.Run", 6 | "language": "dotnet-isolated", 7 | "properties": { 8 | "IsCodeless": false 9 | }, 10 | "bindings": [ 11 | { 12 | "name": "myQueueItem", 13 | "type": "serviceBusTrigger", 14 | "direction": "In", 15 | "dataType": "String", 16 | "queueName": "upper-case", 17 | "connection": "AzureWebJobsServiceBus" 18 | } 19 | ] 20 | } 21 | ] -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/it/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/it/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/it/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/it/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ja/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ja/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ja/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ja/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ko/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ko/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ko/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ko/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 5 | "AzureWebJobsServiceBus":"Endpoint=sb://asafuncacasbnamespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=aG/gQrNF0B5iyrPIdxh6qC1LTJTDGSX9k+ASbCdY6mk=", 6 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" 7 | } 8 | } -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/pl/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/pl/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/pl/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/pl/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/pt-BR/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/pt-BR/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ru/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ru/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/ru/Microsoft.CodeAnalysis.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/ru/Microsoft.CodeAnalysis.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/runtimes/win/lib/netcoreapp2.0/System.Diagnostics.EventLog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/runtimes/win/lib/netcoreapp2.0/System.Diagnostics.EventLog.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/bin/output/tr/Microsoft.CodeAnalysis.CSharp.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/bin/output/tr/Microsoft.CodeAnalysis.CSharp.resources.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 5 | "AzureWebJobsServiceBus":"<<>>", 6 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | using System; 11 | using System.Reflection; 12 | 13 | [assembly: System.Reflection.AssemblyCompanyAttribute("ServiceBusProj")] 14 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 15 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 16 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 17 | [assembly: System.Reflection.AssemblyProductAttribute("ServiceBusProj")] 18 | [assembly: System.Reflection.AssemblyTitleAttribute("ServiceBusProj")] 19 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 20 | 21 | // Generated by the MSBuild WriteCodeFragment class. 22 | 23 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | ac3112c250fe3d24263f780f03ee64dfb190af89 2 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net7.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.InvariantGlobalization = 7 | build_property.PlatformNeutralAssembly = 8 | build_property.EnforceExtendedAnalyzerRules = 9 | build_property._SupportedPlatformList = Linux,macOS,Windows 10 | build_property.RootNamespace = ServiceBusProj 11 | build_property.ProjectDir = c:\Users\raorugan\Documents\Centauri_demo\ServiceBusProj\ 12 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.GlobalUsings.g.cs: -------------------------------------------------------------------------------- 1 | // 2 | global using global::System; 3 | global using global::System.Collections.Generic; 4 | global using global::System.IO; 5 | global using global::System.Linq; 6 | global using global::System.Net.Http; 7 | global using global::System.Threading; 8 | global using global::System.Threading.Tasks; 9 | global using ExecutionContext = global::System.Threading.ExecutionContext; 10 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.assets.cache -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.csproj.AssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.csproj.AssemblyReference.cache -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.csproj.CopyComplete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.csproj.CopyComplete -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 482cc586f255831fff2e527248361cef3396aebf 2 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.genruntimeconfig.cache: -------------------------------------------------------------------------------- 1 | bf90eb83d28d902f065dbdf60d9e6cabd8fccf23 2 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ServiceBusProj.pdb -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/apphost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/apphost.exe -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ref/ServiceBusProj.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/ref/ServiceBusProj.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/refint/ServiceBusProj.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure-functions-on-container-apps/684b31a65cbe15203793e27d34ac322f971601b4/samples/ServiceBus_GitHubActionSample/obj/Debug/net7.0/refint/ServiceBusProj.dll -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/ServiceBusProj.csproj.nuget.dgspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": 1, 3 | "restore": { 4 | "C:\\Users\\raorugan\\Documents\\Centauri_demo\\ServiceBusProj\\ServiceBusProj.csproj": {} 5 | }, 6 | "projects": { 7 | "C:\\Users\\raorugan\\Documents\\Centauri_demo\\ServiceBusProj\\ServiceBusProj.csproj": { 8 | "version": "1.0.0", 9 | "restore": { 10 | "projectUniqueName": "C:\\Users\\raorugan\\Documents\\Centauri_demo\\ServiceBusProj\\ServiceBusProj.csproj", 11 | "projectName": "ServiceBusProj", 12 | "projectPath": "C:\\Users\\raorugan\\Documents\\Centauri_demo\\ServiceBusProj\\ServiceBusProj.csproj", 13 | "packagesPath": "C:\\Users\\raorugan\\.nuget\\packages\\", 14 | "outputPath": "C:\\Users\\raorugan\\Documents\\Centauri_demo\\ServiceBusProj\\obj\\", 15 | "projectStyle": "PackageReference", 16 | "configFilePaths": [ 17 | "C:\\Users\\raorugan\\AppData\\Roaming\\NuGet\\NuGet.Config" 18 | ], 19 | "originalTargetFrameworks": [ 20 | "net7.0" 21 | ], 22 | "sources": { 23 | "https://api.nuget.org/v3/index.json": {} 24 | }, 25 | "frameworks": { 26 | "net7.0": { 27 | "targetAlias": "net7.0", 28 | "projectReferences": {} 29 | } 30 | }, 31 | "warningProperties": { 32 | "warnAsError": [ 33 | "NU1605" 34 | ] 35 | } 36 | }, 37 | "frameworks": { 38 | "net7.0": { 39 | "targetAlias": "net7.0", 40 | "dependencies": { 41 | "Microsoft.Azure.Functions.Worker": { 42 | "target": "Package", 43 | "version": "[1.6.0, )" 44 | }, 45 | "Microsoft.Azure.Functions.Worker.Extensions.ServiceBus": { 46 | "target": "Package", 47 | "version": "[4.2.1, )" 48 | }, 49 | "Microsoft.Azure.Functions.Worker.Sdk": { 50 | "target": "Package", 51 | "version": "[1.7.0, )" 52 | } 53 | }, 54 | "imports": [ 55 | "net461", 56 | "net462", 57 | "net47", 58 | "net471", 59 | "net472", 60 | "net48", 61 | "net481" 62 | ], 63 | "assetTargetFallback": true, 64 | "warn": true, 65 | "frameworkReferences": { 66 | "Microsoft.NETCore.App": { 67 | "privateAssets": "all" 68 | } 69 | }, 70 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.104\\RuntimeIdentifierGraph.json" 71 | } 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/ServiceBusProj.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | $(MSBuildThisFileDirectory)project.assets.json 7 | $(UserProfile)\.nuget\packages\ 8 | C:\Users\raorugan\.nuget\packages\ 9 | PackageReference 10 | 6.4.0 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | C:\Users\raorugan\.nuget\packages\microsoft.codeanalysis.analyzers\3.3.2 20 | C:\Users\raorugan\.nuget\packages\microsoft.azure.functions.worker.sdk.analyzers\1.1.0 21 | C:\Users\raorugan\.nuget\packages\microsoft.azure.functions.worker.sdk\1.7.0 22 | 23 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/obj/ServiceBusProj.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/servicebuscale.js: -------------------------------------------------------------------------------- 1 | const { ServiceBusClient } = require("@azure/service-bus"); 2 | 3 | // connection string to your Service Bus namespace 4 | const connectionString = " { 41 | console.log("Error occurred: ", err); 42 | process.exit(1); 43 | }); 44 | -------------------------------------------------------------------------------- /samples/ServiceBus_GitHubActionSample/workflows/main.yml: -------------------------------------------------------------------------------- 1 | #This workflow will build a container image and deploy it to an Azure Functions App when a commit is pushed to your default branch. 2 | # 3 | # This workflow assumes you have already created the target Azure Functions app. 4 | # 5 | # To configure this workflow: 6 | # 1. Set up the following secrets in your repository: 7 | # - AZURE_RBAC_CREDENTIALS 8 | # - REGISTRY_USERNAME 9 | # - REGISTRY_PASSWORD 10 | # 2. Change env variables for your configuration. 11 | # 12 | # For more information on: 13 | # - GitHub Actions for Azure: https://github.com/Azure/Actions 14 | # - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential 15 | # 16 | # For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp 17 | 18 | name: Deployment for cp-centauri-site 19 | 20 | on: 21 | push: 22 | branches: 23 | [ main ] 24 | 25 | permissions: 26 | contents: read 27 | 28 | env: 29 | AZURE_FUNCTION_APP_NAME: <<>> # set this to your function app name on Azure 30 | AZURE_RESOURCE_GROUP_NAME: << >> # set this to your resource group name on Azure 31 | LOGIN_SERVER: << >> # set this to login server for your private container registry (e.g. 'contoso.azurecr.io', 'docker.io' ) 32 | NAMESPACE: << >> # set this to proper value for NAMESPACE 33 | IMAGE: << >> # set this to proper value for IMAGE 34 | TAG: << >> # set this to proper value for TAG 35 | BUILDPLATFORM: linux/amd64 # set for Dockerbuild targeting Linux on Azure (AMD) 36 | 37 | jobs: 38 | build: 39 | runs-on: ubuntu-latest 40 | 41 | steps: 42 | - name: Checkout to the branch 43 | uses: actions/checkout@v2 44 | 45 | - name: Set up Docker Buildx 46 | uses: docker/setup-buildx-action@v1 47 | 48 | - name: Log in to container registry 49 | uses: docker/login-action@v1 50 | with: 51 | registry: ${{ env.LOGIN_SERVER }} 52 | username: ${{ secrets.REGISTRY_USERNAME }} 53 | password: ${{ secrets.REGISTRY_PASSWORD }} 54 | 55 | - name: Build and push container image to registry 56 | uses: docker/build-push-action@v2 57 | with: 58 | push: true 59 | tags: ${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }} 60 | # file: ./Dockerfile 61 | context: ./ 62 | 63 | 64 | deploy: 65 | runs-on: ubuntu-latest 66 | needs: build 67 | 68 | steps: 69 | - name: Azure Login 70 | uses: azure/login@v1 71 | with: 72 | creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} 73 | 74 | - name: Deploy to functionapp 75 | uses: azure/CLI@v1 76 | with: 77 | azcliversion: 2.47.0 78 | inlineScript: | 79 | az config set extension.use_dynamic_install=yes_without_prompt 80 | az functionapp config container set -n ${{ env.AZURE_FUNCTION_APP_NAME }} -g ${{ env.AZURE_RESOURCE_GROUP_NAME }} --image ${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }} --registry-server ${{ env.LOGIN_SERVER }} --registry-username ${{ secrets.REGISTRY_USERNAME }} --registry-password ${{ secrets.REGISTRY_PASSWORD }} 81 | - name: Azure logout 82 | run: | 83 | az logout 84 | 85 | -------------------------------------------------------------------------------- /samples/TimerTriggerSample/.dockerignore: -------------------------------------------------------------------------------- 1 | local.settings.json -------------------------------------------------------------------------------- /samples/TimerTriggerSample/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:7.0 AS installer-env 2 | 3 | COPY . /src/dotnet-function-app 4 | RUN cd /src/dotnet-function-app && \ 5 | mkdir -p /home/site/wwwroot && \ 6 | dotnet publish *.csproj --output /home/site/wwwroot 7 | 8 | # To enable ssh & remote debugging on app service change the base image to the one below 9 | # FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated7.0-appservice 10 | FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated7.0 11 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 12 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true 13 | 14 | COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] -------------------------------------------------------------------------------- /samples/TimerTriggerSample/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Hosting; 2 | 3 | var host = new HostBuilder() 4 | .ConfigureFunctionsWorkerDefaults() 5 | .Build(); 6 | 7 | host.Run(); 8 | -------------------------------------------------------------------------------- /samples/TimerTriggerSample/Readme.md: -------------------------------------------------------------------------------- 1 | # TimerTrigger Project 2 | 3 | This project contains an Azure Functions application that uses a TimerTrigger. 4 | 5 | ## Overview 6 | 7 | The TimerTrigger makes it incredibly straightforward to execute a function on a schedule. This project demonstrates how to set up a function that runs at a set interval, using CRON expression for scheduling. 8 | 9 | ## Getting Started 10 | 11 | ### Prerequisites 12 | 13 | - An Azure account with an active subscription. 14 | - Azure Functions Core Tools - version 4.0.5455 + 15 | - .NET 7.01 16 | - Azure CLI 17 | 18 | ### Local Development 19 | 20 | Clone the repository and navigate to the TimerTrigger project folder. 21 | 22 | ```bash 23 | git clone 24 | cd TimerTrigger 25 | ``` 26 | --- 27 | 28 | Follow the steps from [here](https://github.com/Azure/azure-functions-on-container-apps/blob/main/README.md#build-the-container-image-and-test-locally) to build, test and push 29 | the Timertrigger image to the container registry of your choice. Post the execution of func start or docker run monitor the function logs to ensure the jobs executed successfully in the 30 | scheduled time. 31 | 32 | ### Deploy to Azure 33 | 34 | Follow the steps [here](https://github.com/Azure/azure-functions-on-container-apps/blob/main/README.md#create-azure-resources) to deploy the image as functions container and monitor 35 | the Live Metrics and Traces tables in AppInsights to ensure the job executed successfully in the scheduled time. 36 | 37 | ### Reference 38 | Refer to following link for more function [samples](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer) of various languages 39 | 40 | ### Contributing 41 | Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests. 42 | 43 | ### License 44 | This project is licensed under the MIT License - see the LICENSE.md file for details. 45 | -------------------------------------------------------------------------------- /samples/TimerTriggerSample/TimerProject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net7.0 4 | v4 5 | Exe 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | PreserveNewest 18 | 19 | 20 | PreserveNewest 21 | Never 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /samples/TimerTriggerSample/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | }, 9 | "enableLiveMetricsFilters": true 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/TimerTriggerSample/timerfunc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Azure.Functions.Worker; 3 | using Microsoft.Extensions.Logging; 4 | using Microsoft.Azure.WebJobs; 5 | 6 | namespace TimerProject 7 | { 8 | public class timerfunc 9 | { 10 | private readonly ILogger _logger; 11 | 12 | public timerfunc(ILoggerFactory loggerFactory) 13 | { 14 | _logger = loggerFactory.CreateLogger(); 15 | } 16 | 17 | [Function("timerfunc")] 18 | public void Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer) 19 | { 20 | _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); 21 | 22 | if (myTimer.ScheduleStatus is not null) 23 | { 24 | _logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}"); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/VolumeMountsSample/README.md: -------------------------------------------------------------------------------- 1 | # Functions on ACA - Volume mounts sample 2 | 3 | ## Overview 4 | 5 | This is a sample project to get started with Volume mounts on Functions on ACA. 6 | It creates a storage account with file share. Configures the storage on ACA environment resource, and then sets up storage mount on the Function on ACA resource using the ACA env storage details. 7 | 8 | Setting use_nfs_mount = true in the parameters will create a vnet and a premium storage with nfs based file share with related setup and use it in the ACA env. 9 | 10 | ## How to configure storage mounts for Fn on ACA 11 | 12 | Storage mount creation and connection setup is done at Environment level similar to regular ACA apps as documented at [how to set up storage mounts in Container App Environment](https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?tabs=smb&pivots=azure-resource-manager). 13 | 14 | To bring in the configured storage mounts as "volumes" for Fn on ACA, we can use the currently available storage account configuration API under websites , with few variations wrt the properties in [AzureStorageInfoValue](https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/create-or-update-configuration?view=rest-appservice-2023-12-01&tabs=HTTP#azurestorageinfovalue): 15 | 16 | - `accessKey`: Not applicable for Functions on ACA as connection setup is done at environment level. Can be skipped or set as empty. 17 | - `accountName`: Should be the name of storage resource configured under Container Apps Environment. 18 | Note: If this is set as empty, it will be considered an [`EmptyDir` (Replica scoped storage type)](https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?tabs=smb&pivots=azure-resource-manager#replica-scoped-storage) 19 | - `mountPath` - Path within the container at which the volume should be mounted. 20 | - `protocol` – Nfs or Smb. (Http is not supported). 21 | Note: This is ignored when accountName is empty, as protocol is not applicable for EmptyDir storage type. 22 | - `shareName` – This can be used to provide [`subpath`](https://learn.microsoft.com/en-us/rest/api/containerapps/container-apps/get?view=rest-containerapps-2024-03-01&tabs=HTTP#volumemount) which is the path within the volume from which the container's volume should be mounted. Defaults to "" 23 | - `state` – This is not supported and always set to OK 24 | - `type` – Only `AzureFiles` is supported for Fn on ACA. 25 | 26 | ## Resource creation 27 | 28 | - One of the ways to deploy these bicep templates is by opening them in vscode and [using bicep extension to deploy them](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/visual-studio-code?tabs=CLI#deploy-bicep-file). 29 | - After installing the bicep extension, right click on the `index.bicep` and choose `Deploy Bicep File...` 30 | - Note: You can change the dep_name to generate new set of resources everytime. 31 | 32 | ## Updating the image 33 | 34 | - This infra deploys the function app using default sample image: `mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0` 35 | - Sample python function code which reads and writes to the mount path is provided under `code` folder as reference. 36 | - Build your image for your fn app and push it to an ACR, and then use Portal's Configuration blade to pick an image from your ACR. -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/.dockerignore: -------------------------------------------------------------------------------- 1 | local.settings.json -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/.funcignore: -------------------------------------------------------------------------------- 1 | .git* 2 | .vscode 3 | __azurite_db*__.json 4 | __blobstorage__ 5 | __queuestorage__ 6 | local.settings.json 7 | test 8 | .venv -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | db.sqlite3 61 | 62 | # Flask stuff: 63 | instance/ 64 | .webassets-cache 65 | 66 | # Scrapy stuff: 67 | .scrapy 68 | 69 | # Sphinx documentation 70 | docs/_build/ 71 | 72 | # PyBuilder 73 | target/ 74 | 75 | # Jupyter Notebook 76 | .ipynb_checkpoints 77 | 78 | # IPython 79 | profile_default/ 80 | ipython_config.py 81 | 82 | # pyenv 83 | .python-version 84 | 85 | # pipenv 86 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 87 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 88 | # having no cross-platform support, pipenv may install dependencies that don’t work, or not 89 | # install all needed dependencies. 90 | #Pipfile.lock 91 | 92 | # celery beat schedule file 93 | celerybeat-schedule 94 | 95 | # SageMath parsed files 96 | *.sage.py 97 | 98 | # Environments 99 | .env 100 | .venv 101 | env/ 102 | venv/ 103 | ENV/ 104 | env.bak/ 105 | venv.bak/ 106 | 107 | # Spyder project settings 108 | .spyderproject 109 | .spyproject 110 | 111 | # Rope project settings 112 | .ropeproject 113 | 114 | # mkdocs documentation 115 | /site 116 | 117 | # mypy 118 | .mypy_cache/ 119 | .dmypy.json 120 | dmypy.json 121 | 122 | # Pyre type checker 123 | .pyre/ 124 | 125 | # Azure Functions artifacts 126 | bin 127 | obj 128 | appsettings.json 129 | local.settings.json 130 | 131 | # Azurite artifacts 132 | __blobstorage__ 133 | __queuestorage__ 134 | __azurite_db*__.json 135 | .python_packages -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-azuretools.vscode-azurefunctions", 4 | "ms-python.python" 5 | ] 6 | } -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Attach to Python Functions", 6 | "type": "debugpy", 7 | "request": "attach", 8 | "connect": { 9 | "host": "localhost", 10 | "port": 9091 11 | }, 12 | "preLaunchTask": "func: host start" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "azureFunctions.deploySubpath": ".", 3 | "azureFunctions.scmDoBuildDuringDeployment": true, 4 | "azureFunctions.pythonVenv": ".venv", 5 | "azureFunctions.projectLanguage": "Python", 6 | "azureFunctions.projectRuntime": "~4", 7 | "debug.internalConsoleOptions": "neverOpen", 8 | "azureFunctions.projectLanguageModel": 2 9 | } -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "func", 6 | "label": "func: host start", 7 | "command": "host start", 8 | "problemMatcher": "$func-python-watch", 9 | "isBackground": true, 10 | "dependsOn": "pip install (functions)" 11 | }, 12 | { 13 | "label": "pip install (functions)", 14 | "type": "shell", 15 | "osx": { 16 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" 17 | }, 18 | "windows": { 19 | "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt" 20 | }, 21 | "linux": { 22 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" 23 | }, 24 | "problemMatcher": [] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/Dockerfile: -------------------------------------------------------------------------------- 1 | # To enable ssh & remote debugging on app service change the base image to the one below 2 | # FROM mcr.microsoft.com/azure-functions/python:4-python3.11-appservice 3 | FROM mcr.microsoft.com/azure-functions/python:4-python3.11 4 | 5 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 6 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true 7 | 8 | COPY requirements.txt / 9 | RUN pip install -r /requirements.txt 10 | 11 | COPY . /home/site/wwwroot -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/function_app.py: -------------------------------------------------------------------------------- 1 | import azure.functions as func 2 | import logging 3 | import os 4 | 5 | app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) 6 | 7 | @app.route(route="http_trigger") 8 | def http_trigger(req: func.HttpRequest) -> func.HttpResponse: 9 | logging.info('Python HTTP trigger function processed a request.') 10 | 11 | file_path = os.path.join("/mount-path", 'myfile.txt') 12 | logging.info(f"File path: {file_path}") 13 | name = req.params.get('name') 14 | if name: 15 | try: 16 | # Open and read the file 17 | with open(file_path, 'w+') as file: 18 | file.write(name) 19 | 20 | # Return the content of the file as the response 21 | return func.HttpResponse("wrote sucessfully to the file", status_code=200) 22 | 23 | except Exception as e: 24 | # Handle any errors that occur 25 | return func.HttpResponse(f"Error: {str(e)}", status_code=500) 26 | 27 | if not name: 28 | try: 29 | # Open and read the file 30 | with open(file_path, 'r') as file: 31 | content = file.read() 32 | 33 | # Return the content of the file as the response 34 | return func.HttpResponse(content, status_code=200) 35 | 36 | except Exception as e: 37 | # Handle any errors that occur 38 | return func.HttpResponse(f"Error: {str(e)}", status_code=500) 39 | 40 | -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | }, 11 | "extensionBundle": { 12 | "id": "Microsoft.Azure.Functions.ExtensionBundle", 13 | "version": "[4.*, 5.0.0)" 14 | } 15 | } -------------------------------------------------------------------------------- /samples/VolumeMountsSample/code/requirements.txt: -------------------------------------------------------------------------------- 1 | # DO NOT include azure-functions-worker in this file 2 | # The Python Worker is managed by Azure Functions platform 3 | # Manually managing azure-functions-worker may cause unexpected issues 4 | 5 | azure-functions 6 | -------------------------------------------------------------------------------- /samples/VolumeMountsSample/infra/index.bicep: -------------------------------------------------------------------------------- 1 | targetScope = 'subscription' 2 | 3 | param dep_name string 4 | param location string 5 | param use_nfs_mount bool 6 | param sub_path string 7 | param use_read_only bool 8 | 9 | var suffix = uniqueString(dep_name, subscription().id) 10 | 11 | resource rg 'Microsoft.Resources/resourceGroups@2023-07-01' = { 12 | name: 'rg-${dep_name}' 13 | location: location 14 | } 15 | 16 | module volumemount 'volumemount.bicep' = { 17 | name: 'volumemount-${suffix}' 18 | scope: rg 19 | params: { 20 | suffix: suffix 21 | use_nfs_mount: use_nfs_mount 22 | sub_path: sub_path 23 | use_read_only: use_read_only 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /samples/VolumeMountsSample/infra/index.bicepparam: -------------------------------------------------------------------------------- 1 | using './index.bicep' 2 | 3 | // Location to create the resources in. 4 | param location = 'eastus' 5 | 6 | // Change this param to deploy a new set of resources. 7 | param dep_name = 'fnacavol' 8 | 9 | // Change this param to use NFS mount instead of SMB. 10 | param use_nfs_mount = false 11 | 12 | // Use this to provide a sub-path in a fileshare for the volume mount. 13 | param sub_path = '' 14 | 15 | // Use this to mount the volume as read-only. 16 | param use_read_only = false 17 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/.azure/config.json: -------------------------------------------------------------------------------- 1 | {"version":1,"defaultEnvironment":"azddaprv1"} 2 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Azure Developer CLI", 3 | "image": "mcr.microsoft.com/devcontainers/python:3.10-bullseye", 4 | "features": { 5 | // See https://containers.dev/features for list of features 6 | "ghcr.io/devcontainers/features/docker-in-docker:2": { 7 | }, 8 | "ghcr.io/azure/azure-dev/azd:latest": {} 9 | }, 10 | "customizations": { 11 | "vscode": { 12 | "extensions": [ 13 | "GitHub.vscode-github-actions", 14 | "ms-azuretools.azure-dev", 15 | "ms-azuretools.vscode-azurefunctions", 16 | "ms-azuretools.vscode-bicep", 17 | "ms-azuretools.vscode-docker" 18 | // Include other VSCode language extensions if needed 19 | // Right click on an extension inside VSCode to add directly to devcontainer.json, or copy the extension ID 20 | ] 21 | } 22 | }, 23 | "forwardPorts": [ 24 | // Forward ports if needed for local development 25 | ], 26 | "postCreateCommand": "", 27 | "remoteUser": "vscode", 28 | "hostRequirements": { 29 | "memory": "8gb" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/CreateOrder/Dockerfile: -------------------------------------------------------------------------------- 1 | # To enable ssh & remote debugging on app service change the base image to the one below 2 | # FROM mcr.microsoft.com/azure-functions/python:4-python3.10-appservice 3 | FROM mcr.microsoft.com/azure-functions/python:4-python3.10 4 | 5 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 6 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true\ 7 | AzureWebJobsFeatureFlags=EnableWorkerIndexing 8 | 9 | COPY requirements.txt / 10 | RUN pip install -r /requirements.txt 11 | 12 | COPY . /home/site/wwwroot -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/CreateOrder/components/statestore.yml: -------------------------------------------------------------------------------- 1 | apiVersion: dapr.io/v1alpha1 2 | kind: Component 3 | metadata: 4 | name: statestore 5 | spec: 6 | type: state.azure.blobstorage 7 | version: v1 8 | metadata: 9 | - name: accountName 10 | value: "daprstatestor" 11 | - name: accountKey 12 | value: "" 13 | - name: containerName 14 | value: "" 15 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/CreateOrder/extensions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | 5 | ** 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/CreateOrder/function_app.py: -------------------------------------------------------------------------------- 1 | import json 2 | import azure.functions as func 3 | import logging 4 | 5 | dapp = func.DaprFunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) 6 | 7 | # Dapr service invocation trigger 8 | @dapp.function_name(name="CreateOrder") 9 | @dapp.dapr_service_invocation_trigger(arg_name="payload", method_name="CreateOrder") 10 | @dapp.dapr_state_outreput(arg_name="state", state_store="%StateStoName%", key="order") 11 | def main(payload: str, state: func.Out[str] ) : 12 | 13 | logging.info('Azure function triggered by Dapr Service Invocation Trigger.') 14 | logging.info("Dapr service invocation trigger payload: %s", payload) 15 | state.set(payload) 16 | 17 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/CreateOrder/getting_started.md: -------------------------------------------------------------------------------- 1 | ## Getting Started with Azure Function 2 | ### Last updated: March 8th 2021 3 | 4 | #### Project Structure 5 | The main project folder () can contain the following files: 6 | 7 | * **local.settings.json** - Used to store app settings and connection strings when running locally. This file doesn't get published to Azure. To learn more, see [local.settings.file](https://aka.ms/azure-functions/python/local-settings). 8 | * **requirements.txt** - Contains the list of Python packages the system installs when publishing to Azure. 9 | * **host.json** - Contains global configuration options that affect all functions in a function app. This file does get published to Azure. Not all options are supported when running locally. To learn more, see [host.json](https://aka.ms/azure-functions/python/host.json). 10 | * **.vscode/** - (Optional) Contains store VSCode configuration. To learn more, see [VSCode setting](https://aka.ms/azure-functions/python/vscode-getting-started). 11 | * **.venv/** - (Optional) Contains a Python virtual environment used by local development. 12 | * **Dockerfile** - (Optional) Used when publishing your project in a [custom container](https://aka.ms/azure-functions/python/custom-container). 13 | * **tests/** - (Optional) Contains the test cases of your function app. For more information, see [Unit Testing](https://aka.ms/azure-functions/python/unit-testing). 14 | * **.funcignore** - (Optional) Declares files that shouldn't get published to Azure. Usually, this file contains .vscode/ to ignore your editor setting, .venv/ to ignore local Python virtual environment, tests/ to ignore test cases, and local.settings.json to prevent local app settings being published. 15 | 16 | Each function has its own code file and binding configuration file ([**function.json**](https://aka.ms/azure-functions/python/function.json)). 17 | 18 | #### Developing your first Python function using VS Code 19 | 20 | If you have not already, please checkout our [quickstart](https://aka.ms/azure-functions/python/quickstart) to get you started with Azure Functions developments in Python. 21 | 22 | #### Publishing your function app to Azure 23 | 24 | For more information on deployment options for Azure Functions, please visit this [guide](https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python#publish-the-project-to-azure). 25 | 26 | #### Next Steps 27 | 28 | * To learn more about developing Azure Functions, please visit [Azure Functions Developer Guide](https://aka.ms/azure-functions/python/developer-guide). 29 | 30 | * To learn more specific guidance on developing Azure Functions with Python, please visit [Azure Functions Developer Python Guide](https://aka.ms/azure-functions/python/python-developer-guide). -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/CreateOrder/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/CreateOrder/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "FUNCTIONS_WORKER_RUNTIME": "python", 5 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 6 | "StateStoreName": "statestore", 7 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES" : 1, 8 | "DAPR_APP_PORT": "3001" , 9 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" 10 | } 11 | } -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/CreateOrder/requirements.txt: -------------------------------------------------------------------------------- 1 | # Do not include azure-functions-worker in this file 2 | # The Python Worker is managed by the Azure Functions platform 3 | # Manually managing azure-functions-worker may cause unexpected issues 4 | 5 | azure-functions==1.18.0b1 -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/.dockerignore: -------------------------------------------------------------------------------- 1 | local.settings.json -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | csx 4 | .vs 5 | edge 6 | Publish 7 | 8 | *.user 9 | *.suo 10 | *.cscfg 11 | *.Cache 12 | project.lock.json 13 | 14 | /packages 15 | /TestResults 16 | 17 | /tools/NuGet.exe 18 | /App_Data 19 | /secrets 20 | /data 21 | .secrets 22 | appsettings.json 23 | local.settings.json 24 | 25 | node_modules 26 | dist 27 | 28 | # Local python packages 29 | .python_packages/ 30 | 31 | # Python Environments 32 | .env 33 | .venv 34 | env/ 35 | venv/ 36 | ENV/ 37 | env.bak/ 38 | venv.bak/ 39 | 40 | # Byte-compiled / optimized / DLL files 41 | __pycache__/ 42 | *.py[cod] 43 | *$py.class 44 | 45 | # Azurite artifacts 46 | __blobstorage__ 47 | __queuestorage__ 48 | __azurite_db*__.json -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/Dockerfile: -------------------------------------------------------------------------------- 1 | # To enable ssh & remote debugging on app service change the base image to the one below 2 | # FROM mcr.microsoft.com/azure-functions/python:4-python3.10-appservice 3 | FROM mcr.microsoft.com/azure-functions/python:4-python3.10 4 | 5 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ 6 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true\ 7 | AzureWebJobsFeatureFlags=EnableWorkerIndexing 8 | 9 | COPY requirements.txt / 10 | RUN pip install -r /requirements.txt 11 | 12 | COPY . /home/site/wwwroot 13 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/extensions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | 5 | ** 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/function_app.py: -------------------------------------------------------------------------------- 1 | import json 2 | import azure.functions as func 3 | import logging 4 | 5 | 6 | dapp = func.DaprFunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) 7 | 8 | # Service invoke another Dapr API 9 | @dapp.function_name(name="InvokeOutputBinding") 10 | @dapp.route(route="invoke", auth_level=dapp.auth_level.ANONYMOUS) 11 | @dapp.dapr_invoke_output(arg_name = "payload", app_id = "%Appid%", method_name = "%methodname%", http_verb = "post") 12 | 13 | # Python Http Azure Function 14 | def main(req: func.HttpRequest, payload: func.Out[str] ) -> str: 15 | 16 | 17 | logging.info('Python HTTP trigger function processed a request..') 18 | logging.info(req.params) 19 | data = req.params.get('data') 20 | if not data: 21 | try: 22 | req_body = req.get_json() 23 | except ValueError: 24 | pass 25 | else: 26 | data = req_body.get('data') 27 | 28 | if data: 29 | logging.info(f"Url: {req.url}, Data: {data}") 30 | payload.set(json.dumps({"body": data}).encode('utf-8')) 31 | return 'Successfully performed service invocation using Dapr invoke output binding.' 32 | else: 33 | return func.HttpResponse( 34 | "Please pass a data on the query string or in the request body", 35 | status_code=400 36 | ) -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/getting_started.md: -------------------------------------------------------------------------------- 1 | ## Getting Started with Azure Function 2 | ### Last updated: March 8th 2021 3 | 4 | #### Project Structure 5 | The main project folder () can contain the following files: 6 | 7 | * **local.settings.json** - Used to store app settings and connection strings when running locally. This file doesn't get published to Azure. To learn more, see [local.settings.file](https://aka.ms/azure-functions/python/local-settings). 8 | * **requirements.txt** - Contains the list of Python packages the system installs when publishing to Azure. 9 | * **host.json** - Contains global configuration options that affect all functions in a function app. This file does get published to Azure. Not all options are supported when running locally. To learn more, see [host.json](https://aka.ms/azure-functions/python/host.json). 10 | * **.vscode/** - (Optional) Contains store VSCode configuration. To learn more, see [VSCode setting](https://aka.ms/azure-functions/python/vscode-getting-started). 11 | * **.venv/** - (Optional) Contains a Python virtual environment used by local development. 12 | * **Dockerfile** - (Optional) Used when publishing your project in a [custom container](https://aka.ms/azure-functions/python/custom-container). 13 | * **tests/** - (Optional) Contains the test cases of your function app. For more information, see [Unit Testing](https://aka.ms/azure-functions/python/unit-testing). 14 | * **.funcignore** - (Optional) Declares files that shouldn't get published to Azure. Usually, this file contains .vscode/ to ignore your editor setting, .venv/ to ignore local Python virtual environment, tests/ to ignore test cases, and local.settings.json to prevent local app settings being published. 15 | 16 | Each function has its own code file and binding configuration file ([**function.json**](https://aka.ms/azure-functions/python/function.json)). 17 | 18 | #### Developing your first Python function using VS Code 19 | 20 | If you have not already, please checkout our [quickstart](https://aka.ms/azure-functions/python/quickstart) to get you started with Azure Functions developments in Python. 21 | 22 | #### Publishing your function app to Azure 23 | 24 | For more information on deployment options for Azure Functions, please visit this [guide](https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python#publish-the-project-to-azure). 25 | 26 | #### Next Steps 27 | 28 | * To learn more about developing Azure Functions, please visit [Azure Functions Developer Guide](https://aka.ms/azure-functions/python/developer-guide). 29 | 30 | * To learn more specific guidance on developing Azure Functions with Python, please visit [Azure Functions Developer Python Guide](https://aka.ms/azure-functions/python/python-developer-guide). -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "FUNCTIONS_WORKER_RUNTIME": "python", 5 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 6 | "Appid": "funcorderapp", 7 | "methodname": "CreateOrder", 8 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES" : 1, 9 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" 10 | } 11 | } -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/CodeSample/HttpFrontEnd/requirements.txt: -------------------------------------------------------------------------------- 1 | # Do not include azure-functions-worker in this file 2 | # The Python Worker is managed by the Azure Functions platform 3 | # Manually managing azure-functions-worker may cause unexpected issues 4 | 5 | azure-functions==1.18.0b1 -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/README.md: -------------------------------------------------------------------------------- 1 | # Azure Developer CLI (azd) Deployment steps 2 | 3 | A starter blueprint for getting your application up on Azure using [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/overview) (azd). Add your application code, write Infrastructure as Code assets in [Bicep](https://aka.ms/bicep) to get your application up and running quickly. 4 | 5 | The following assets have been provided: 6 | 7 | - Infrastructure-as-code (IaC) Bicep files under the `infra` folder that demonstrate how to provision resources and setup resource tagging for azd. 8 | - A [dev container](https://containers.dev) configuration file under the `.devcontainer` directory that installs infrastructure tooling by default. This can be readily used to create cloud-hosted developer environments such as [GitHub Codespaces](https://aka.ms/codespaces). 9 | - Continuous deployment workflows for CI providers such as GitHub Actions under the `.github` directory, and Azure Pipelines under the `.azdo` directory that work for most use-cases. 10 | 11 | ## Next Steps 12 | 1. Clone the repo or use code spaces 13 | 2. Go to folder consisting of azd code 14 | 3. Go to infra/main.parameters.json and replace the apiImageNameCO and apiImageNameHP values with the respective image url of your container registry. Under CodeSample/ folder in this repo you may find the python Http Function app - CodeSample/HttpFrontEnd and Create Order function app CodeSample/CreateOrder code that you may containerize and upload to the container registry 15 | 4. In the terminal execute and provide inputs such as subscription, Azure region to deploy the Azure resources 16 | 17 | ```sh 18 | Run azd env new (provide a new environment name) 19 | Then run azd up 20 | ``` 21 | - Run `azd up` to validate both infrastructure and application code changes. 22 | - Run `azd deploy` to validate application code changes only. 23 | 24 | Optionally you may visit Azure portal and navigate to the Deployment under the Resource Group created to monitor the deployment progress and Azure resources that are created 25 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/azure.yaml: -------------------------------------------------------------------------------- 1 | # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json 2 | 3 | # This is an example starter azure.yaml file containing several example services in comments below. 4 | # Make changes as needed to describe your application setup. 5 | # To learn more about the azure.yaml file, visit https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/azd-schema 6 | 7 | # Name of the application. 8 | name: azd-starter 9 | # services: 10 | # ## An example for a python API service. 11 | # ## The service is named 'python-api'. 12 | # ## The language is 'python'. 13 | # ## The source code is located in the project (azure.yaml) directory. 14 | # ## The service will be hosted on Azure App Service. 15 | # python-api: 16 | # language: python 17 | # project: ./ 18 | # host: appservice 19 | # ## An example for a NodeJS API, located in src/api. 20 | # nodejs-api: 21 | # language: js 22 | # project: ./src/api 23 | # host: appservice 24 | # ## An example for a React front-end app. 25 | # ## The src/react-app/build folder is where the app is built to after `npm run build`. 26 | # react-web: 27 | # language: js 28 | # project: ./src/react-app 29 | # host: appservice 30 | # dist: build 31 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/infra/main.bicep: -------------------------------------------------------------------------------- 1 | targetScope = 'subscription' 2 | 3 | // The main bicep module to provision Azure resources. 4 | // For a more complete walkthrough to understand how this file works with azd, 5 | // see https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/make-azd-compatible?pivots=azd-create 6 | 7 | @minLength(1) 8 | @maxLength(64) 9 | @description('Name of the the environment which is used to generate a short unique hash used in all resources.') 10 | param environmentName string 11 | 12 | @minLength(1) 13 | @description('Primary location for all resources') 14 | param location string 15 | 16 | @description('The image name for the create order service') 17 | param apiImageNameCO string = '' 18 | 19 | @description('The image name for the Http front end service') 20 | param apiImageNameHP string = '' 21 | 22 | // Optional parameters to override the default azd resource naming conventions. 23 | // Add the following to main.parameters.json to provide values: 24 | // "resourceGroupName": { 25 | // "value": "myGroupName" 26 | // } 27 | param resourceGroupName string = '' 28 | 29 | var abbrs = loadJsonContent('./abbreviations.json') 30 | 31 | // tags that should be applied to all resources. 32 | var tags = { 33 | // Tag all resources with the environment name. 34 | 'azd-env-name': environmentName 35 | } 36 | 37 | 38 | #disable-next-line no-unused-vars 39 | var apiServiceName = 'funconaca-api' 40 | 41 | // Organize resources in a resource group 42 | resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { 43 | name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}' 44 | location: location 45 | tags: tags 46 | } 47 | 48 | 49 | 50 | // Add resources to be provisioned below. 51 | // A full example that leverages azd bicep modules can be seen in the todo-python-mongo template: 52 | // https://github.com/Azure-Samples/todo-python-mongo/tree/main/infra 53 | 54 | 55 | module azfunctionappCO './core/function.bicep' = { 56 | name: 'co' 57 | scope: resourceGroup 58 | params: { 59 | location: location 60 | environmentName: environmentName 61 | apiImageNameCO: apiImageNameCO 62 | apiImageNameHP: apiImageNameHP 63 | 64 | } 65 | } 66 | 67 | 68 | // Add outputs from the deployment here, if needed. 69 | // 70 | // This allows the outputs to be referenced by other bicep deployments in the deployment pipeline, 71 | // or by the local machine as a way to reference created resources in Azure for local development. 72 | // Secrets should not be added here. 73 | // 74 | // Outputs are automatically saved in the local azd environment .env file. 75 | // To see these outputs, run `azd env get-values`, or `azd env get-values --output json` for json output. 76 | output AZURE_LOCATION string = location 77 | output AZURE_TENANT_ID string = tenant().tenantId 78 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/infra/main.parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "environmentName": { 6 | "value": "${AZURE_ENV_NAME}" 7 | }, 8 | "location": { 9 | "value": "${AZURE_LOCATION}" 10 | }, 11 | "apiImageNameCO": { 12 | "value": "" 13 | }, 14 | "apiImageNameHP": { 15 | "value": "" 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /samples/azdsampleDAPRandFunctionsonACA/samplerequest.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | url = '' 5 | 6 | payload = { 7 | "data": { 8 | "value": { 9 | "orderId": "1446" 10 | } 11 | } 12 | } 13 | 14 | headers = { 15 | 'Content-Type': 'application/json' 16 | } 17 | 18 | response = requests.post(url, headers=headers, data=json.dumps(payload)) 19 | 20 | print(response.status_code) 21 | print(response.text) 22 | -------------------------------------------------------------------------------- /samples/azdtemplates/.gitignore: -------------------------------------------------------------------------------- 1 | .azure -------------------------------------------------------------------------------- /samples/azdtemplates/README.md: -------------------------------------------------------------------------------- 1 | # Azure Developer CLI (azd) Azure Functions on Azure Container Apps Starter 2 | 3 | A starter blueprint for getting your application up on Azure using [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/overview) (azd). Add your application code, write Infrastructure as Code assets in [Bicep](https://aka.ms/bicep) to get your application up and running quickly. 4 | 5 | The following assets have been provided: 6 | 7 | - Infrastructure-as-code (IaC) Bicep files under the `infra` folder that demonstrate how to provision resources and setup resource tagging for azd. 8 | 9 | 10 | ## Next Steps 11 | 1. Clone the repo or use code spaces 12 | 2. Go to folder consisting of azd code 13 | 3. Go to infra/main.parameters.json and replace the apiImageName with your image url of your container registry 14 | 2. In the terminal execute and provide inputs such as subscription, Azure region to deploy the Azure resources 15 | 16 | ```sh 17 | Run azd env new (provide a new environment name) 18 | Then run azd up 19 | ``` 20 | - Run `azd up` to validate both infrastructure and application code changes. 21 | - Run `azd deploy` to validate application code changes only. 22 | 23 | Optionally you may visit Azure portal and navigate to the Deployment under the Resource Group created to monitor the deployment progress and Azure resources that are created 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/azdtemplates/azure.yaml: -------------------------------------------------------------------------------- 1 | # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json 2 | 3 | # This is an example starter azure.yaml file containing several example services in comments below. 4 | # Make changes as needed to describe your application setup. 5 | # To learn more about the azure.yaml file, visit https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/azd-schema 6 | 7 | # Name of the application. 8 | name: azd-starter 9 | # services: 10 | # ## An example for a python API service. 11 | # ## The service is named 'python-api'. 12 | # ## The language is 'python'. 13 | # ## The source code is located in the project (azure.yaml) directory. 14 | # ## The service will be hosted on Azure App Service. 15 | # python-api: 16 | # language: python 17 | # project: ./ 18 | # host: appservice 19 | # ## An example for a NodeJS API, located in src/api. 20 | # nodejs-api: 21 | # language: js 22 | # project: ./src/api 23 | # host: appservice 24 | # ## An example for a React front-end app. 25 | # ## The src/react-app/build folder is where the app is built to after `npm run build`. 26 | # react-web: 27 | # language: js 28 | # project: ./src/react-app 29 | # host: appservice 30 | # dist: build 31 | -------------------------------------------------------------------------------- /samples/azdtemplates/infra/core/function.bicep: -------------------------------------------------------------------------------- 1 | 2 | //@minLength(1) 3 | //@maxLength(64) 4 | @description('Name of the the environment which is used to generate a short unique hash used in all resources.') 5 | param environmentName string 6 | 7 | @minLength(1) 8 | @description('Primary location for all resources') 9 | param location string 10 | 11 | @description('The image name for the api service') 12 | param apiImageName string = '' 13 | 14 | 15 | // Generate a unique token to be used in naming resources. 16 | // Remove linter suppression after using. 17 | #disable-next-line no-unused-vars 18 | var resourceToken = toLower(uniqueString(subscription().id, environmentName, location)) 19 | 20 | 21 | #disable-next-line no-unused-vars 22 | var apiServiceName = 'function-onaca' 23 | 24 | var prefix = '${environmentName}-${resourceToken}' 25 | 26 | 27 | 28 | resource azStorageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = { 29 | name: '${toLower(take(replace(prefix, '-', ''), 17))}storage' 30 | location: location 31 | kind: 'StorageV2' 32 | sku: { 33 | name: 'Standard_LRS' 34 | } 35 | } 36 | var azStorageConnectionString = 'DefaultEndpointsProtocol=https;AccountName=${azStorageAccount.name};EndpointSuffix=${az.environment().suffixes.storage};AccountKey=${azStorageAccount.listKeys().keys[0].value}' 37 | 38 | resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = { 39 | name: 'log-${resourceToken}' 40 | location: location 41 | properties: any({ 42 | retentionInDays: 30 43 | features: { 44 | searchVersion: 1 45 | } 46 | sku: { 47 | name: 'PerGB2018' 48 | } 49 | }) 50 | } 51 | 52 | resource applicationInsightsResources 'Microsoft.Insights/components@2020-02-02' = { 53 | name: 'applicationinsights-${resourceToken}' 54 | location: location 55 | kind: 'web' 56 | properties: { 57 | Application_Type: 'web' 58 | WorkspaceResourceId: logAnalyticsWorkspace.id 59 | IngestionMode: 'LogAnalytics' 60 | } 61 | } 62 | 63 | 64 | resource environment 'Microsoft.App/managedEnvironments@2022-10-01' = { 65 | name: '${take(prefix,4)}-containerapps-env' 66 | location: location 67 | properties: {} 68 | } 69 | 70 | resource azfunctionapp 'Microsoft.Web/sites@2022-09-01' = { 71 | name: 'funcapp-${take(resourceToken,4)}' 72 | location: location 73 | kind: 'functionapp' 74 | properties: { 75 | managedEnvironmentId: environment.id 76 | //name: '${prefix}-funcapp' 77 | siteConfig: { 78 | linuxFxVersion: 'DOCKER|${apiImageName}' 79 | appSettings: [ 80 | { 81 | name: 'AzureWebJobsStorage' 82 | value: azStorageConnectionString 83 | } 84 | { 85 | name: 'APPINSIGHTS_INSTRUMENTATIONKEY' 86 | value: applicationInsightsResources.properties.InstrumentationKey 87 | } 88 | ] 89 | } 90 | } 91 | } 92 | 93 | 94 | 95 | 96 | 97 | 98 | // Add outputs from the deployment here, if needed. 99 | // 100 | // This allows the outputs to be referenced by other bicep deployments in the deployment pipeline, 101 | // or by the local machine as a way to reference created resources in Azure for local development. 102 | // Secrets should not be added here. 103 | // 104 | // Outputs are automatically saved in the local azd environment .env file. 105 | // To see these outputs, run `azd env get-values`, or `azd env get-values --output json` for json output. 106 | output AZURE_LOCATION string = location 107 | output AZURE_TENANT_ID string = tenant().tenantId 108 | output functionAppName string = azfunctionapp.name 109 | -------------------------------------------------------------------------------- /samples/azdtemplates/infra/main.bicep: -------------------------------------------------------------------------------- 1 | targetScope = 'subscription' 2 | 3 | 4 | 5 | @minLength(1) 6 | @maxLength(64) 7 | @description('Name of the the environment which is used to generate a short unique hash used in all resources.') 8 | param environmentName string 9 | 10 | @minLength(1) 11 | @description('Primary location for all resources') 12 | param location string 13 | 14 | @description('The image name for the api service') 15 | param apiImageName string = '' 16 | 17 | 18 | param resourceGroupName string = '' 19 | 20 | var abbrs = loadJsonContent('./abbreviations.json') 21 | 22 | // tags that should be applied to all resources. 23 | var tags = { 24 | // Tag all resources with the environment name. 25 | 'azd-env-name': environmentName 26 | } 27 | 28 | 29 | #disable-next-line no-unused-vars 30 | var apiServiceName = 'funconaca-api' 31 | 32 | // Organize resources in a resource group 33 | resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { 34 | name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}' 35 | location: location 36 | tags: tags 37 | } 38 | 39 | module functionApp './core/function.bicep' = { 40 | name: 'func' 41 | scope: resourceGroup 42 | params: { 43 | location: location 44 | environmentName: environmentName 45 | apiImageName: apiImageName 46 | 47 | 48 | } 49 | } 50 | 51 | // Add outputs from the deployment here, if needed. 52 | // 53 | // This allows the outputs to be referenced by other bicep deployments in the deployment pipeline, 54 | // or by the local machine as a way to reference created resources in Azure for local development. 55 | // Secrets should not be added here. 56 | // 57 | // Outputs are automatically saved in the local azd environment .env file. 58 | // To see these outputs, run `azd env get-values`, or `azd env get-values --output json` for json output. 59 | output AZURE_LOCATION string = location 60 | output AZURE_TENANT_ID string = tenant().tenantId 61 | -------------------------------------------------------------------------------- /samples/azdtemplates/infra/main.parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "environmentName": { 6 | "value": "${AZURE_ENV_NAME}" 7 | }, 8 | "location": { 9 | "value": "${AZURE_LOCATION}" 10 | }, 11 | "apiImageName": { 12 | "value": "" 13 | } 14 | } 15 | } 16 | --------------------------------------------------------------------------------