Web server component using Azure Virtual Machine
Basic example of an Azure web server accessible over HTTP
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set classic-azure-ts-webserver-componentcd pulumi-examples/classic-azure-ts-webserver-componentThis 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#
Deploying the example#
-
Create a new stack:
Terminal window pulumi stack init dev -
Log in to the Azure CLI (you will be prompted to do this during deployment if you forget this step):
Terminal window az login -
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. Note that
--secretensures your password is encrypted safely.Terminal window pulumi config set azure:location westus # any valid Azure region will dopulumi config set azure:subscriptionId <YOUR_SUBSCRIPTION_ID>pulumi config set username webmasterpulumi config set password <your-password> --secretpulumi config set count 5 # optional -- will default to 2 if left out -
Install dependencies:
Terminal window npm install -
Deploy the stack:
Terminal window pulumi upPreviewing changes:...Performing changes:...info: 15 changes performed:+ 15 resources createdUpdate duration: 4m27s -
Check the resulting IP addresses:
Terminal window pulumi stack output ipAddresses[ 40.112.181.239, ..., 40.112.181.240 ]
Cleaning up#
Once you are done, you can destroy all of the resources, and the stack:
pulumi destroypulumi stack rm