Build your first serverless app by using Azure Logic Apps and Azure Functions in Visual Studio

You can quickly develop and deploy cloud apps by using the serverless tools and capabilities in Azure, such as Azure Logic Apps and Azure Functions. This article shows how to start building a serverless app, which uses a logic app that calls an Azure function, in Visual Studio. To learn more about serverless solutions in Azure, see Azure Serverless with Functions and Logic Apps.

Prerequisites

To build a serverless app in Visual Studio, you need:

Create a resource group project

To get started, create an Azure Resource Group project for your serverless app. In Azure, you create resources within a resource group, which is a logical collection you use for organizing, managing, and deploying resources for an entire app as a single asset. For a serverless app in Azure, your resource group includes resources for both Azure Logic Apps and Azure Functions. Learn more about Azure resource groups and resources.

  1. Start Visual Studio and sign in by using your Azure account.

  2. On the File menu, select New > Project.

    Create new project in Visual Studio

  3. Under Installed, select Visual C# or Visual Basic. Then, select Cloud > Azure Resource Group.

    Note

    If the Cloud category or Azure Resource Group project doesn't exist, make sure that you installed the Azure SDK for Visual Studio.

    If you're using Visual Studio 2019, follow these steps:

    1. In the Create a new project box, select the Azure Resource Group project template for either Visual C# or Visual Basic, and then select Next.

    2. Provide the name and other project information that you want to use for the Azure resource group. When you're done, select Create.

  4. Give your project a name and a location, and then select OK.

    Visual Studio prompts you to select a template from the templates list. This example uses an Azure QuickStart template so that you can build a serverless app that includes a logic app and a call to an Azure function.

    Tip

    In scenarios where you don't want to predeploy your solution into an Azure resource group, you can use the blank Logic App template, which just creates an empty logic app.

  5. From the Show templates from this location list, select Azure QuickStart (github.com/Azure/azure-quickstart-templates).

  6. In the search box, enter "logic-app" as your filter. From the results, select the 101-logic-app-and-function-app template.

    Select Azure QuickStart template

    Visual Studio creates and opens a solution for your resource group project. The Azure QuickStart template that you selected creates a deployment template named azuredeploy.json inside your resource group project. This deployment template includes the definition for a simple logic app that is triggered by an HTTP request, calls an Azure function, and returns the result as an HTTP response.

    New serverless solution

  7. Next, deploy your solution to Azure. You must do this before you can open the deployment template and review the resources for your serverless app.

Deploy your solution

Before you can open your logic app in the Logic App Designer in Visual Studio, you must have an Azure resource group that's already deployed in Azure. The designer can then create connections to resources and services in your logic app. For this task, follow these steps to deploy your solution from Visual Studio to the Azure portal:

  1. In Solution Explorer, from your resource project's shortcut menu, select Deploy > New.

    Create new deployment for resource group

  2. If they're not already selected, select your Azure subscription and the resource group to which you want to deploy. Then, select Deploy.

    Deployment settings

  3. If the Edit Parameters box appears, provide the resource names to use for your logic app and your Azure function app at deployment, and then save your settings. Make sure you use a globally unique name for your function app.

    Provide names for your logic app and function app

    When Visual Studio starts deployment to your specified resource group, your solution's deployment status appears in the Visual Studio Output window. After deployment finishes, your logic app is live in the Azure portal.

Edit your logic app in Visual Studio

To edit your logic app after deployment, open your logic app by using the Logic App Designer in Visual Studio.

  1. In Solution Explorer, from the shortcut menu of the azuredeploy.json file, select Open With Logic App Designer.

    Open azuredeploy.json in Logic App Designer

    Tip

    If you don't have this command in Visual Studio 2019, check that you have the latest updates for Visual Studio.

  2. After the Logic App Properties box appears, under Subscription, select your Azure subscription if it's not already selected. Under Resource Group, select the resource group and location where you deployed your solution, and then select OK.

    Logic app properties

    After the Logic App Designer opens, you can continue adding steps or change the workflow, and save your updates.

    Opened logic app in Logic App Designer

Create your Azure Functions project

To create your Functions project and function by using JavaScript, Python, F#, PowerShell, Batch, or Bash, follow the steps in Work with Azure Functions Core Tools. To develop your Azure function by using C# inside your solution, use a C# class library by following the steps in Publish a .NET class library as a Function App.

Deploy functions from Visual Studio

Your deployment template deploys any Azure functions that you have in your solution from the Git repo that's specified by variables in the azuredeploy.json file. If you create and author your Functions project in your solution, you can check that project into Git source control (for example, GitHub or Azure DevOps) and then update the repo variable so that the template deploys your Azure function.

Manage logic apps and view run history

For logic apps already deployed in Azure, you can still edit, manage, view run history for, and disable those apps from Visual Studio.

  1. From the View menu in Visual Studio, open Cloud Explorer.

  2. Under All subscriptions, select the Azure subscription associated with the logic apps that you want to manage, and then select Apply.

  3. Under Logic Apps, select your logic app. From that app's shortcut menu, select Open with Logic App Editor.

    Tip

    If you don't have this command in Visual Studio 2019, check that you have the latest updates for Visual Studio.

You can now download the already published logic app into your resource group project. So, although you might have started a logic app in the Azure portal, you can still import and manage that app in Visual Studio. For more information, see Manage logic apps with Visual Studio.

Next steps