Web Server Component Using Azure Virtual Machine | TypeScript
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
WebServer class, we can hide many details (see here for its definition).
- Download and install the Pulumi CLI
- Connect Pulumi with your Azure account (if your
azCLI is configured, no further changes are required)
Running the App
Create a new stack:
$ pulumi stack init dev
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
--secretensures your password is encrypted safely.
Login to Azure CLI (you will be prompted to do this during deployment if you forget this step):
$ az login
Restore NPM dependencies:
$ npm install
pulumi upto preview and deploy changes:
$ pulumi up Previewing changes: ... Performing changes: ... info: 15 changes performed: + 15 resources created Update duration: 4m27s
Check the resulting IP addresses:
$ pulumi stack output ipAddresses [ 188.8.131.52, ..., 184.108.40.206 ]