1. Packages
  2. Azure Classic
  3. How-to Guides
  4. Web Server Component Using Azure Virtual Machine

We recommend using Azure Native.

Azure Classic v5.72.0 published on Monday, Apr 15, 2024 by Pulumi

Web Server Component Using Azure Virtual Machine

azure logo

We recommend using Azure Native.

Azure Classic v5.72.0 published on Monday, Apr 15, 2024 by Pulumi

    View Code Deploy

    This example provisions a configurable number of Linux web servers in an Azure Virtual Machine, and returns the resulting public IP addresses. This example uses a reusable Pulumi component to simplify the creation of new virtual machines. By defining a WebServer class, we can hide many details (see here for its definition).

    Prerequisites

    Running the App

    1. Create a new stack:

      $ pulumi stack init dev
      
    2. Configure the 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.

      $ pulumi config set azure:location westus  # any valid Azure region will do
      $ pulumi config set username webmaster
      $ pulumi config set password <your-password> --secret
      $ pulumi config set count 5                # optional -- will default to 2 if left out
      

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

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

      $ az login
      
    4. Restore NPM dependencies:

      $ npm install
      
    5. Run pulumi up to preview and deploy changes:

      $ pulumi up
      Previewing changes:
      ...
      
      Performing changes:
      ...
      info: 15 changes performed:
          + 15 resources created
      Update duration: 4m27s
      
    6. Check the resulting IP addresses:

      $ pulumi stack output ipAddresses
      [ 40.112.181.239, ..., 40.112.181.240 ]
      
    azure logo

    We recommend using Azure Native.

    Azure Classic v5.72.0 published on Monday, Apr 15, 2024 by Pulumi