1. Packages
  2. Azure Native
  3. How-to Guides
  4. Web Server Using Azure Virtual Machine
This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
Azure Native v2.34.0 published on Thursday, Mar 28, 2024 by Pulumi

Web Server Using Azure Virtual Machine

azure-native logo
This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
Azure Native v2.34.0 published on Thursday, Mar 28, 2024 by Pulumi

    View Code Deploy

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

    Prerequisites

    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
      
    2. 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.

      $ 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.

    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: 7 changes performed:
          + 7 resources created
      Update duration: 2m38s
      
    6. Check the IP address:

      $ pulumi stack output ipAddress
      40.112.181.239
      
    azure-native logo
    This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
    Azure Native v2.34.0 published on Thursday, Mar 28, 2024 by Pulumi