title | description | services | documentationcenter | author | manager | ms.assetid | ms.service | ms.devlang | ms.topic | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Create an Azure Function that connects to an Azure Cosmos DB | Microsoft Docs |
Azure CLI Script Sample - Create an Azure Function that connects to an Azure Cosmos DB |
functions |
functions |
ggailey777 |
jeconnoc |
azure-functions |
azurecli |
sample |
07/03/2018 |
glenga |
mvc |
This Azure Functions sample script creates a function app and connects the function to an Azure Cosmos DB database. The created app setting that contains the connection can be used with an Azure Cosmos DB trigger or binding.
[!INCLUDE quickstarts-free-trial-note]
[!INCLUDE cloud-shell-try-it.md]
If you use the CLI locally, make sure that you are running the Azure CLI version 2.0 or later. To find the version, run az --version
. If you need to install or upgrade, see Install the Azure CLI.
This sample creates an Azure Function app and adds a Cosmos DB endpoint and access key to app settings.
[!code-azurecli-interactivemain]
[!INCLUDE cli-script-clean-up]
This script uses the following commands: Each command in the table links to command specific documentation.
Command | Notes |
---|---|
az group create | Create a resource group with location |
az storage accounts create | Create a storage account |
az functionapp create | Creates a function app in the serverless consumption plan. |
az cosmosdb create | Create an Azure Cosmos DB database. |
For more information on the Azure CLI, see Azure CLI documentation.
Additional Azure Functions CLI script samples can be found in the Azure Functions documentation.