From 7184fdfafe0e2000bd07c68909d4f8aedde9086f Mon Sep 17 00:00:00 2001 From: Mikhail Shilkov Date: Tue, 28 Apr 2020 09:02:29 +0200 Subject: [PATCH] Add an example of Azure Function on Linux App Service (#664) --- Examples.sln | 8 +- README.md | 3 +- .../.gitignore | 0 .../Azure.Functions.csproj | 0 .../FunctionsStack.cs | 0 .../Program.cs | 0 .../Pulumi.yaml | 0 .../README.md | 2 +- .../functions/Functions.csproj | 0 .../functions/Hello.cs | 0 .../functions/host.json | 0 .../functions/local.settings.json | 0 azure-cs-functions-linux-app/.gitignore | 353 ++++++++++++++++++ .../Azure.Functions.LinuxApp.csproj | 13 + .../FunctionsStack.cs | 89 +++++ azure-cs-functions-linux-app/Program.cs | 9 + azure-cs-functions-linux-app/Pulumi.yaml | 3 + azure-cs-functions-linux-app/README.md | 66 ++++ .../functions/Hello/__init__.py | 7 + .../functions/Hello/function.json | 20 + .../functions/host.json | 3 + .../functions/requirements.txt | 1 + azure-fs-aci/Azure.Aci.fsproj | 2 +- 23 files changed, 575 insertions(+), 4 deletions(-) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/.gitignore (100%) rename azure-cs-functions-raw/Azure.FunctionsRaw.csproj => azure-cs-functions-consumption/Azure.Functions.csproj (100%) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/FunctionsStack.cs (100%) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/Program.cs (100%) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/Pulumi.yaml (100%) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/README.md (93%) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/functions/Functions.csproj (100%) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/functions/Hello.cs (100%) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/functions/host.json (100%) rename {azure-cs-functions-raw => azure-cs-functions-consumption}/functions/local.settings.json (100%) create mode 100644 azure-cs-functions-linux-app/.gitignore create mode 100644 azure-cs-functions-linux-app/Azure.Functions.LinuxApp.csproj create mode 100644 azure-cs-functions-linux-app/FunctionsStack.cs create mode 100644 azure-cs-functions-linux-app/Program.cs create mode 100644 azure-cs-functions-linux-app/Pulumi.yaml create mode 100644 azure-cs-functions-linux-app/README.md create mode 100644 azure-cs-functions-linux-app/functions/Hello/__init__.py create mode 100644 azure-cs-functions-linux-app/functions/Hello/function.json create mode 100644 azure-cs-functions-linux-app/functions/host.json create mode 100644 azure-cs-functions-linux-app/functions/requirements.txt diff --git a/Examples.sln b/Examples.sln index b45e88909..c416268f8 100644 --- a/Examples.sln +++ b/Examples.sln @@ -15,7 +15,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Aks", "azure-cs-aks\A EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.KeyVault", "azure-cs-msi-keyvault-rbac\Azure.KeyVault.csproj", "{79319396-C17A-4DBB-92B2-7291D39E0B70}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.FunctionsRaw", "azure-cs-functions-raw\Azure.FunctionsRaw.csproj", "{8C01B8EF-B770-4817-98F2-F7FC6F2B2A74}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Functions", "azure-cs-functions-consumption\Azure.Functions.csproj", "{8C01B8EF-B770-4817-98F2-F7FC6F2B2A74}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aws.WebServer", "aws-cs-webserver\Aws.WebServer.csproj", "{C0F20B39-07D0-4118-A48F-6D3911673424}" EndProject @@ -49,6 +49,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kubernetes.Guestbook.Compon EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "testing-unit-cs\UnitTesting.csproj", "{7A9FC7DC-DC35-4033-B4FF-E9EFB3E6EBB8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.LinuxApp", "azure-cs-functions-linux-app\Azure.Functions.LinuxApp.csproj", "{B3739A06-5343-4990-A48B-E5BEFAC5678A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -147,6 +149,10 @@ Global {7A9FC7DC-DC35-4033-B4FF-E9EFB3E6EBB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {7A9FC7DC-DC35-4033-B4FF-E9EFB3E6EBB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {7A9FC7DC-DC35-4033-B4FF-E9EFB3E6EBB8}.Release|Any CPU.Build.0 = Release|Any CPU + {B3739A06-5343-4990-A48B-E5BEFAC5678A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3739A06-5343-4990-A48B-E5BEFAC5678A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3739A06-5343-4990-A48B-E5BEFAC5678A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3739A06-5343-4990-A48B-E5BEFAC5678A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/README.md b/README.md index d82848093..11827d935 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,8 @@ Example | Description | [App Service](azure-cs-appservice) | Build a web application hosted in App Service and provision Azure SQL Database and Azure Application Insights. [Bot Service](azure-cs-botservice) | Build an Azure Bot Service hosted in Azure App Service. [Cosmos App Component](azure-cs-cosmosapp-component) | Use a reusable component to create globally-distributed applications with Azure Cosmos DB. -[Functions - Raw](azure-cs-functions-raw) | Deploy a function to Azure Functions created from raw deployment packages in C#. +[Functions - .NET on Consumption](azure-cs-functions-consumption) | Deploy a .NET Azure Function running on a Windows Consumption Plan. +[Functions - Python on Linux App Service](azure-cs-functions-linux-app) | Deploy a Python Azure Function running on a Linux App Service Premium Plan. [MSI Key Vault RBAC](azure-cs-msi-keyvault-rbac) | Use a managed identity with Azure App Service to access Azure KeyVault, Azure Storage, and Azure SQL Database without passwords or secrets. [Static Website](azure-cs-static-website) | Deploy a Static Website to Azure Storage. [Web Server](azure-cs-webserver) | Deploy a Virtual Machine and start an HTTP server on it. diff --git a/azure-cs-functions-raw/.gitignore b/azure-cs-functions-consumption/.gitignore similarity index 100% rename from azure-cs-functions-raw/.gitignore rename to azure-cs-functions-consumption/.gitignore diff --git a/azure-cs-functions-raw/Azure.FunctionsRaw.csproj b/azure-cs-functions-consumption/Azure.Functions.csproj similarity index 100% rename from azure-cs-functions-raw/Azure.FunctionsRaw.csproj rename to azure-cs-functions-consumption/Azure.Functions.csproj diff --git a/azure-cs-functions-raw/FunctionsStack.cs b/azure-cs-functions-consumption/FunctionsStack.cs similarity index 100% rename from azure-cs-functions-raw/FunctionsStack.cs rename to azure-cs-functions-consumption/FunctionsStack.cs diff --git a/azure-cs-functions-raw/Program.cs b/azure-cs-functions-consumption/Program.cs similarity index 100% rename from azure-cs-functions-raw/Program.cs rename to azure-cs-functions-consumption/Program.cs diff --git a/azure-cs-functions-raw/Pulumi.yaml b/azure-cs-functions-consumption/Pulumi.yaml similarity index 100% rename from azure-cs-functions-raw/Pulumi.yaml rename to azure-cs-functions-consumption/Pulumi.yaml diff --git a/azure-cs-functions-raw/README.md b/azure-cs-functions-consumption/README.md similarity index 93% rename from azure-cs-functions-raw/README.md rename to azure-cs-functions-consumption/README.md index 0077834da..1e16785be 100644 --- a/azure-cs-functions-raw/README.md +++ b/azure-cs-functions-consumption/README.md @@ -2,7 +2,7 @@ # Azure Functions -Azure Functions created from raw deployment packages in C#. +Azure Functions created from deployment packages in C# and deployed to a Consumption Plan on Windows. ## Deploying the App diff --git a/azure-cs-functions-raw/functions/Functions.csproj b/azure-cs-functions-consumption/functions/Functions.csproj similarity index 100% rename from azure-cs-functions-raw/functions/Functions.csproj rename to azure-cs-functions-consumption/functions/Functions.csproj diff --git a/azure-cs-functions-raw/functions/Hello.cs b/azure-cs-functions-consumption/functions/Hello.cs similarity index 100% rename from azure-cs-functions-raw/functions/Hello.cs rename to azure-cs-functions-consumption/functions/Hello.cs diff --git a/azure-cs-functions-raw/functions/host.json b/azure-cs-functions-consumption/functions/host.json similarity index 100% rename from azure-cs-functions-raw/functions/host.json rename to azure-cs-functions-consumption/functions/host.json diff --git a/azure-cs-functions-raw/functions/local.settings.json b/azure-cs-functions-consumption/functions/local.settings.json similarity index 100% rename from azure-cs-functions-raw/functions/local.settings.json rename to azure-cs-functions-consumption/functions/local.settings.json diff --git a/azure-cs-functions-linux-app/.gitignore b/azure-cs-functions-linux-app/.gitignore new file mode 100644 index 000000000..e64527066 --- /dev/null +++ b/azure-cs-functions-linux-app/.gitignore @@ -0,0 +1,353 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ diff --git a/azure-cs-functions-linux-app/Azure.Functions.LinuxApp.csproj b/azure-cs-functions-linux-app/Azure.Functions.LinuxApp.csproj new file mode 100644 index 000000000..78048120d --- /dev/null +++ b/azure-cs-functions-linux-app/Azure.Functions.LinuxApp.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp3.1 + enable + + + + + + + diff --git a/azure-cs-functions-linux-app/FunctionsStack.cs b/azure-cs-functions-linux-app/FunctionsStack.cs new file mode 100644 index 000000000..6fe39d1f9 --- /dev/null +++ b/azure-cs-functions-linux-app/FunctionsStack.cs @@ -0,0 +1,89 @@ +// Copyright 2016-2020, Pulumi Corporation. All rights reserved. + +using Pulumi; +using Pulumi.Azure.AppInsights; +using Pulumi.Azure.AppService; +using Pulumi.Azure.AppService.Inputs; +using Pulumi.Azure.Core; +using Pulumi.Azure.Storage; + +class FunctionsStack : Stack +{ + public FunctionsStack() + { + var resourceGroup = new ResourceGroup("functions-rg"); + + var storageAccount = new Account("sa", new AccountArgs + { + ResourceGroupName = resourceGroup.Name, + AccountReplicationType = "LRS", + AccountTier = "Standard" + }); + + var appServicePlan = new Plan("functions-linux-asp", new PlanArgs + { + ResourceGroupName = resourceGroup.Name, + + // Run on Linux + Kind = "Linux", + + // Premium SKU + Sku = new PlanSkuArgs + { + Tier = "PremiumV2", + Size = "P1v2" + }, + + // For Linux, you need to change the plan to have Reserved = true property. + Reserved = true + }); + + var container = new Container("zips", new ContainerArgs + { + StorageAccountName = storageAccount.Name, + ContainerAccessType = "private" + }); + + var blob = new Blob("zip", new BlobArgs + { + StorageAccountName = storageAccount.Name, + StorageContainerName = container.Name, + Type = "Block", + Source = new FileArchive("./functions") + }); + + var codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount); + + // Application insights + var insights = new Insights("functions-ai", new InsightsArgs + { + ResourceGroupName = resourceGroup.Name, + ApplicationType = "web" + }); + + var app = new FunctionApp("app", new FunctionAppArgs + { + ResourceGroupName = resourceGroup.Name, + AppServicePlanId = appServicePlan.Id, + AppSettings = + { + {"runtime", "python"}, + {"FUNCTIONS_WORKER_RUNTIME", "python"}, + {"WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl}, + {"APPLICATIONINSIGHTS_CONNECTION_STRING", Output.Format($"InstrumentationKey={insights.InstrumentationKey}")} + }, + StorageConnectionString = storageAccount.PrimaryConnectionString, + Version = "~3", + OsType = "linux", + SiteConfig = new FunctionAppSiteConfigArgs + { + AlwaysOn = true, + LinuxFxVersion = "DOCKER|mcr.microsoft.com/azure-functions/python:2.0" + } + }); + + this.Endpoint = Output.Format($"https://{app.DefaultHostname}/api/Hello?name=Pulumi"); + } + + [Output] public Output Endpoint { get; set; } +} diff --git a/azure-cs-functions-linux-app/Program.cs b/azure-cs-functions-linux-app/Program.cs new file mode 100644 index 000000000..f23c25128 --- /dev/null +++ b/azure-cs-functions-linux-app/Program.cs @@ -0,0 +1,9 @@ +// Copyright 2016-2020, Pulumi Corporation. All rights reserved. + +using System.Threading.Tasks; +using Pulumi; + +class Program +{ + static Task Main() => Deployment.RunAsync(); +} diff --git a/azure-cs-functions-linux-app/Pulumi.yaml b/azure-cs-functions-linux-app/Pulumi.yaml new file mode 100644 index 000000000..8729dbbe0 --- /dev/null +++ b/azure-cs-functions-linux-app/Pulumi.yaml @@ -0,0 +1,3 @@ +name: azure-cs-functions-linuxapp +description: Creates Azure Functions on a Linux App Service Plan +runtime: dotnet diff --git a/azure-cs-functions-linux-app/README.md b/azure-cs-functions-linux-app/README.md new file mode 100644 index 000000000..812ab3912 --- /dev/null +++ b/azure-cs-functions-linux-app/README.md @@ -0,0 +1,66 @@ +[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new) + +# Azure Functions on a Linux App Service Plan + +Azure Functions created from deployment packages in Python and deployed to an App Service Plan on Linux. + +## Deploying the App + +To deploy your infrastructure, follow the below steps. + +### Prerequisites + +1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/) +2. [Install .NET Core 3.1+](https://dotnet.microsoft.com/download) + +### Steps + +1. Create a new stack: + + ``` + $ pulumi stack init dev + ``` + +1. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step): + + ``` + $ az login + ``` + +1. Configure the location to deploy the resources to: + + ``` + $ pulumi config set azure:location + ``` + +1. Run `pulumi up` to preview and deploy changes: + + ``` + $ pulumi up + Previewing update (dev): + ... + + Updating (dev): + ... + Resources: + + 7 created + Duration: 2m42s + ``` + +1. Check the deployed function endpoints: + + ``` + $ pulumi stack output Endpoint + https://app1a2d3e4d.azurewebsites.net/api/Hello?name=Pulumi + $ curl "$(pulumi stack output Endpoint)" + Hello, Pulumi + ``` + +1. From there, feel free to experiment. Simply making edits and running `pulumi up` will incrementally update your stack. + +1. Once you've finished experimenting, tear down your stack's resources by destroying and removing it: + + ```bash + $ pulumi destroy --yes + $ pulumi stack rm --yes + ``` diff --git a/azure-cs-functions-linux-app/functions/Hello/__init__.py b/azure-cs-functions-linux-app/functions/Hello/__init__.py new file mode 100644 index 000000000..b453e5c9e --- /dev/null +++ b/azure-cs-functions-linux-app/functions/Hello/__init__.py @@ -0,0 +1,7 @@ +import azure.functions as func + +def main(req: func.HttpRequest) -> func.HttpResponse: + body = 'Hello {}'.format(req.params.get('name')) + return func.HttpResponse( + body, + status_code=200) diff --git a/azure-cs-functions-linux-app/functions/Hello/function.json b/azure-cs-functions-linux-app/functions/Hello/function.json new file mode 100644 index 000000000..4667f0aca --- /dev/null +++ b/azure-cs-functions-linux-app/functions/Hello/function.json @@ -0,0 +1,20 @@ +{ + "scriptFile": "__init__.py", + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "get", + "post" + ] + }, + { + "type": "http", + "direction": "out", + "name": "$return" + } + ] +} \ No newline at end of file diff --git a/azure-cs-functions-linux-app/functions/host.json b/azure-cs-functions-linux-app/functions/host.json new file mode 100644 index 000000000..83a921673 --- /dev/null +++ b/azure-cs-functions-linux-app/functions/host.json @@ -0,0 +1,3 @@ +{ + "version": "2.0" +} \ No newline at end of file diff --git a/azure-cs-functions-linux-app/functions/requirements.txt b/azure-cs-functions-linux-app/functions/requirements.txt new file mode 100644 index 000000000..75db2c4f6 --- /dev/null +++ b/azure-cs-functions-linux-app/functions/requirements.txt @@ -0,0 +1 @@ +azure-functions diff --git a/azure-fs-aci/Azure.Aci.fsproj b/azure-fs-aci/Azure.Aci.fsproj index 26785555c..182501ccb 100644 --- a/azure-fs-aci/Azure.Aci.fsproj +++ b/azure-fs-aci/Azure.Aci.fsproj @@ -12,7 +12,7 @@ - +