Skip to main content

Search the Dev Center

Search tutorials, templates, examples, and more.

Todo app using Azure App Service with SQL Database integrated with Azure DevOps

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set classic-azure-ts-appservice-devops
cd pulumi-examples/classic-azure-ts-appservice-devops

A Todo List application from Azure Samples GitHub: .NET Core MVC sample for Azure App Service, a web app built with ASP.NET Core, Entity Framework Core and a SQL database.

Provisions Azure SQL Database and Azure Application Insights to be used in combination with App Service. Defines an Azure DevOps pipeline to deploy in a CI/CD environment.

Prerequisites#

  1. Install Pulumi
  2. Configure Azure credentials
  3. Install Node.js

Deploying the example#

  1. Build and publish the ASP.NET Core project:

    Terminal window
    dotnet publish src
  2. Navigate to infra:

    Terminal window
    cd infra
  3. Create a new stack:

    Terminal window
    pulumi stack init dev
  4. Log in to the Azure CLI (you will be prompted to do this during deployment if you forget this step):

    Terminal window
    az login
  5. Configure the target Azure environment:

    Terminal window
    pulumi config set azure:location <location>
    pulumi config set azure:subscriptionId <YOUR_SUBSCRIPTION_ID>
  6. Define the SQL Server username:

    Terminal window
    pulumi config set sqlUsername <value>
  7. Define the SQL Server password (make it complex enough to satisfy Azure policy):

    Terminal window
    pulumi config set --secret sqlPassword <value>
  8. Install dependencies:

    Terminal window
    npm install
  9. Deploy the stack:

    Terminal window
    pulumi up
    Previewing changes:
    ...
    Performing changes:
    ...
    info: 10 changes performed:
    + 10 resources created
    Update duration: 1m14.59910109s
  10. Check the deployed website endpoint:

    Terminal window
    pulumi stack output endpoint
    curl "$(pulumi stack output endpoint)"
    https://dev-as10d706a2.azurewebsites.net
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Index - My ToDoList App</title>
    ...

Integrating with Azure DevOps#

azure-pipeline.yml in the root folder of this example shows a configuration for Azure DevOps using the Pulumi task.

The Pulumi task expects a Pulumi access token to be configured as a build variable. Copy your token from the Access Tokens page and put it into the pulumi.access.token build variable.

The alternative-pipeline folder contains custom scripts and a pipeline to run the Pulumi program in environments that do not have access to the marketplace.

Follow the Azure DevOps guide for more details.

Cleaning up#

Once you are done, you can destroy all of the resources, and the stack:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.