---
title: "Web Server Using Azure Virtual Machine"
description: "Basic example of an Azure web server accessible over HTTP"
url: "https://www.pulumi.com/dev/examples/azure-ts-webserver/"
image: "https://www.pulumi.com/assets/og/dev/examples/azure-ts-webserver.png"
---

# Web Server Using Azure Virtual Machine

Basic example of an Azure web server accessible over HTTP

- Source on GitHub: https://github.com/pulumi/examples/tree/master/azure-ts-webserver
- Deploy with Pulumi: https://app.pulumi.com/new?template=https%3A%2F%2Fgithub.com%2Fpulumi%2Fexamples%2Ftree%2Fmaster%2Fazure-ts-webserver

## Get started with this example

This example lives in the [pulumi/examples](https://github.com/pulumi/examples/tree/master/azure-ts-webserver) repo. Pull down just this directory to follow along:

```bash
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set azure-ts-webserver
cd pulumi-examples/azure-ts-webserver
```

This example provisions a Linux web server in an Azure Virtual Machine and gives it a public IP address.

## Prerequisites

- [Node.js](https://nodejs.org/en/download/)
- [Download and install the Pulumi CLI](https://www.pulumi.com/docs/get-started/install/) (you will also need to configure Pulumi for a supported state backend; by default it will use Pulumi Cloud)
- [Connect Pulumi with your Azure account](https://www.pulumi.com/docs/intro/cloud-providers/azure/setup/) (if your `az` CLI is configured, no further changes are required)

## Running the App

These instructions assume you are running all commands in the same folder where the code resides (unless otherwise indicated).

1.  Create a new stack:

    ```
    $ pulumi stack init dev
    ```

1.  Configure the app deployment. The username and password here will be used to configure the Virtual Machine. The
    password must adhere to the [Azure restrictions on VM passwords](
    https://docs.microsoft.com/en-us/azure/virtual-machines/windows/faq#what-are-the-password-requirements-when-creating-a-vm).

    ```
    $ pulumi config set azure-native:location westus    # any valid Azure region will do
    $ pulumi config set username webmaster
    $ pulumi config set password --secret <your-password>
    ```

    Note that `--secret` ensures your password is encrypted safely.

1.  Login to Azure CLI (you will be prompted to do this during deployment if you forget this step):

    ```
    $ az login
    ```

1.  Restore NPM dependencies:

    ```
    $ npm install
    ```

1.  Run `pulumi up` to preview and deploy changes:

    ```
    $ pulumi up
    Previewing changes:
    ...

    Performing changes:
    ...
    info: 7 changes performed:
        + 7 resources created
    Update duration: 2m38s
    ```

1.  Check the IP address:

    ```
    $ pulumi stack output ipAddress
    40.112.181.239
    ```
