Using Locally with the Pulumi Azure Classic Provider

Preview

Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in

Using Locally with the Pulumi Azure Classic Provider

Pulumi is an infrastructure as code tool which uses providers to interact with different clouds - and Locally supports both the Azure Native and the Azure Classic providers.

There are two Pulumi providers for Azure, we're going to use the Azure Classic provider in this guide.

If you'd prefer to use Locally with the Azure Native provider, we have a separate guide covering that.

This guide was tested using the following versions of Pulumi and the Azure Classic provider, but newer versions should work too:

  • pulumi - v3.263.0
  • Azure Classic provider - v6.40.0

Creating a Pulumi Project

Pulumi doesn't ship a first-party template for the Azure Classic provider, so we'll start from the empty Go template and bring in the Classic SDK ourselves. In an empty directory, run:

$ pulumi new go

We're using Golang in this guide, but you should be able to use any Pulumi supported language provided you're using the latest version of the provider.

Following the built-in prompts gives us a scaffolded Pulumi project with an empty main.go. Replace its contents with the Resource Group example from the locallybuild/examples repository:

package main

import (
  "github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
  "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
  pulumi.Run(func(ctx *pulumi.Context) error {
    _, err := core.NewResourceGroup(ctx, "pulumi-resourcegroup", &core.ResourceGroupArgs{
      Location: pulumi.StringPtr("berlin"),
    })
    if err != nil {
      return err
    }

    return nil
  })
}

Then pull in the Azure Classic SDK:

$ go mod tidy

Provisioning a Resource Group

At this point we're ready to provision our infrastructure. If you haven't already started Locally, you can do so using:

$ locally build

Pulumi requires you to be logged in for commands to work. If you're new to Pulumi or haven't done this, at this point you may need to run:

$ pulumi login --local

Since the Pulumi project that we've created sources credentials from the Environment (that is, using Environment Variables) - we can use Automatic Configuration to run this against Locally:

$ locally run pulumi up

When we do, Pulumi will download the required dependencies, provision the infrastructure and then output the result.

With Pulumi having finished provisioning, if we open the First Subscription within the Locally Dashboard, and view the Resource Groups then we should see our newly created Resource Group.

Whilst this example shows how to use the Pulumi Golang SDK to provision a Resource Group, as Pulumi supports different providers and languages for interacting with Azure, you should be able to use Locally with any of them. Just be sure you're using the most recent version of the provider.

Next steps

You can find more examples of how to use Pulumi with Locally in the Examples in the Documentation. To run pulumi up against Locally in your pipeline, see Using Locally in CI.

Should you encounter any issues, please take a look at the troubleshooting section.

Preview

Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in

A local cloud for you and your agents.

Your Azure infrastructure, running on your machine. Deploy in seconds, break things freely, and ship to Azure when you're ready.