Skip to content

Latest commit

 

History

History
86 lines (61 loc) · 4.63 KB

functions-create-first-azure-function-azure-cli-linux.md

File metadata and controls

86 lines (61 loc) · 4.63 KB
title description services keywords author ms.author ms.date ms.topic ms.service ms.custom ms.devlang manager
Create your first function on Linux from the Azure CLI (preview) | Microsoft Docs
Learn how to create your first Azure Function running on a default Linux image using the Azure CLI.
functions
ggailey777
glenga
11/15/2017
quickstart
functions
mvc
azure-cli
cfowler

Create your first function running on Linux using the Azure CLI (preview)

Azure Functions lets you host your functions on Linux in a default Azure App Service container. This functionality is currently in preview. You can also bring your own custom container.

This quickstart topic walks you through how to use Azure Functions with the Azure CLI to create your first function app on Linux hosted on the default App Service container. The function code itself is deployed to the image from a GitHub sample repository.

The following steps are supported on a Mac, Windows, or Linux computer.

Prerequisites

To complete this quickstart, you need:

  • An active Azure subscription.

[!INCLUDE quickstarts-free-trial-note]

[!INCLUDE cloud-shell-try-it.md]

If you choose to install and use the CLI locally, this topic requires the Azure CLI version 2.0.21 or later. Run az --version to find the version you have. If you need to install or upgrade, see Install Azure CLI 2.0.

[!INCLUDE functions-create-resource-group]

[!INCLUDE functions-create-storage-account]

Create a Linux App Service plan

Linux hosting for Functions is currently only supported on an App Service plan. Consumption plan hosting is not yet supported. To learn more about hosting, see Azure Functions hosting plans comparison.

[!INCLUDE app-service-plan-no-h]

Create a function app on Linux

You must have a function app to host the execution of your functions on Linux. The function app provides an environment for execution of your function code. It lets you group functions as a logic unit for easier management, deployment, and sharing of resources. Create a function app by using the az functionapp create command with a Linux App Service plan.

In the following command, substitute a unique function app name where you see the <app_name> placeholder and the storage account name for <storage_name>. The <app_name> is used as the default DNS domain for the function app, and so the name needs to be unique across all apps in Azure. The deployment-source-url parameter is a sample repository in GitHub that contains a "Hello World" HTTP triggered function.

az functionapp create --name <app_name> --storage-account  <storage_name>  --resource-group myResourceGroup \
--plan myAppServicePlan --deployment-source-url https://github.com/Azure-Samples/functions-quickstart-linux

After the function app has been created and deployed, the Azure CLI shows information similar to the following example:

{
  "availabilityState": "Normal",
  "clientAffinityEnabled": true,
  "clientCertEnabled": false,
  "cloningInfo": null,
  "containerSize": 1536,
  "dailyMemoryTimeQuota": 0,
  "defaultHostName": "quickstart.azurewebsites.net",
  "enabled": true,
  "enabledHostNames": [
    "quickstart.azurewebsites.net",
    "quickstart.scm.azurewebsites.net"
  ],
   ....
    // Remaining output has been truncated for readability.
}

Because myAppServicePlan is a Linux plan, the built-in docker image is used to create the container that runs the function app on Linux.

Note

The sample repository currently includes two scripting files, deploy.sh and .deployment. The .deployment file tells the deployment process to use deploy.sh as the custom deployment script. In the current preview release, scripts are required to deploy the function app on a Linux image.

[!INCLUDE functions-test-function-code]

[!INCLUDE functions-cleanup-resources]

[!INCLUDE functions-quickstart-next-steps-cli]