1. Docs
  2. Infrastructure as Code
  3. Get Started
  4. Azure
  5. Create project

Get started with Pulumi and Azure

    Create a new project

    A project is a program in your chosen language that defines a collection of related cloud resources. In this step, you will create a new project.

    Initializing your project

    Each project lives in its own directory. Create a new one:

    $ mkdir quickstart
    
    > mkdir quickstart
    

    Change into the new directory:

    $ cd quickstart
    
    > cd quickstart
    

    Now initialize a new Pulumi project for Azure using the pulumi new command:

    $ pulumi new azure-typescript
    
    > pulumi new azure-typescript
    
    $ pulumi new azure-python
    
    > pulumi new azure-python
    
    $ pulumi new azure-csharp
    
    > pulumi new azure-csharp
    
    $ pulumi new azure-go
    
    > pulumi new azure-go
    
    $ pulumi new azure-java
    
    > pulumi new azure-java
    
    $ pulumi new azure-yaml
    
    > pulumi new azure-yaml
    

    The pulumi new command interactively walks through initializing a new project, as well as creating a stack and configuring it. A stack is an instance of your project and you may have many of them – like dev, staging, and prod – each with different configuration settings.

    You will be prompted for configuration values such as an Azure location. You can hit ENTER to accept the default of WestUS2, or can type in another value such as eastus:

    azure-native:location: The Azure location to use: (WestUS2) eastus
    
    If this is your first time running Pulumi, you will be prompted to log into Pulumi Cloud. This is a free but optional service that makes IaC easy by safely and securely managing state for you. This guide explains what Pulumi Cloud is and this topic describes alternative Pulumi backend options.

    After some dependency installations from npm, the project and stack will be ready.

    After the command completes, the project and stack will be ready.

    After the command completes, the project and stack will be ready.

    After the command completes, the project and stack will be ready.

    After the command completes, the project and stack will be ready.

    After the command completes, the project and stack will be ready.

    Review your new project’s contents

    If you list the contents of your directory, you’ll see some key files:

    • src/main/java/myproject is the project’s Java package root
    • index.js index.ts main.py main.go Program.cs Program.fs Program.vb App.java Pulumi.yaml contains your project’s main code that declares an Azure resource group and storage account

    • Pulumi.yaml is a project file containing metadata about your project like its name

    • Pulumi.yaml is a project file containing metadata about your project, like its name, as well as declaring your project’s resources
    • Pulumi.dev.yaml contains configuration values for the stack you just initialized

    Now examine the code in index.js index.ts __main__.py main.go Program.cs Program.fs Program.vb App.java Pulumi.yaml :

    import * as pulumi from "@pulumi/pulumi";
    import * as resources from "@pulumi/azure-native/resources";
    import * as storage from "@pulumi/azure-native/storage";
    
    // Create an Azure Resource Group
    const resourceGroup = new resources.ResourceGroup("resourceGroup");
    
    // Create an Azure resource (Storage Account)
    const storageAccount = new storage.StorageAccount("sa", {
        resourceGroupName: resourceGroup.name,
        sku: {
            name: storage.SkuName.Standard_LRS,
        },
        kind: storage.Kind.StorageV2,
    });
    
    // Export the storage account name
    export const storageAccountName = storageAccount.name;
    
    """An Azure RM Python Pulumi program"""
    
    import pulumi
    from pulumi_azure_native import storage
    from pulumi_azure_native import resources
    
    # Create an Azure Resource Group
    resource_group = resources.ResourceGroup("resource_group")
    
    # Create an Azure Storage Account
    account = storage.StorageAccount(
        "sa",
        resource_group_name=resource_group.name,
        sku={
            "name": storage.SkuName.STANDARD_LRS,
        },
        kind=storage.Kind.STORAGE_V2,
    )
    
    # Export the storage account name
    pulumi.export("storage_account_name", account.name)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
    	"github.com/pulumi/pulumi-azure-native-sdk/storage/v2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Create an Azure Resource Group
    		resourceGroup, err := resources.NewResourceGroup(ctx, "resourceGroup", nil)
    		if err != nil {
    			return err
    		}
    
    		// Create an Azure resource (Storage Account)
    		storageAccount, err := storage.NewStorageAccount(ctx, "sa", &storage.StorageAccountArgs{
    			ResourceGroupName: resourceGroup.Name,
    			Sku: &storage.SkuArgs{
    				Name: pulumi.String("Standard_LRS"),
    			},
    			Kind: pulumi.String("StorageV2"),
    		})
    		if err != nil {
    			return err
    		}
    
    		// Export the storage account name
    		ctx.Export("storageAccountName", storageAccount.Name)
    		return nil
    	})
    }
    
    using Pulumi;
    using Pulumi.AzureNative.Resources;
    using Pulumi.AzureNative.Storage;
    using Pulumi.AzureNative.Storage.Inputs;
    using System.Collections.Generic;
    
    return await Pulumi.Deployment.RunAsync(() =>
    {
        // Create an Azure Resource Group
        var resourceGroup = new ResourceGroup("resourceGroup");
    
        // Create an Azure resource (Storage Account)
        var storageAccount = new StorageAccount("sa", new StorageAccountArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Sku = new SkuArgs
            {
                Name = SkuName.Standard_LRS
            },
            Kind = Kind.StorageV2
        });
    
        // Export the storage account name
        return new Dictionary<string, object?>
        {
            ["storageAccountName"] = storageAccount.Name
        };
    });
    
    package myproject;
    
    import com.pulumi.Pulumi;
    import com.pulumi.azurenative.resources.ResourceGroup;
    import com.pulumi.azurenative.storage.StorageAccount;
    import com.pulumi.azurenative.storage.StorageAccountArgs;
    import com.pulumi.azurenative.storage.enums.Kind;
    import com.pulumi.azurenative.storage.enums.SkuName;
    import com.pulumi.azurenative.storage.inputs.SkuArgs;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(ctx -> {
                var resourceGroup = new ResourceGroup("resourceGroup");
                var storageAccount = new StorageAccount("sa", StorageAccountArgs.builder()
                        .resourceGroupName(resourceGroup.name())
                        .sku(SkuArgs.builder()
                                .name(SkuName.Standard_LRS)
                                .build())
                        .kind(Kind.StorageV2)
                        .build());
    
                ctx.export("storageAccountName", storageAccount.name());
            });
        }
    }
    
    name: quickstart
    runtime: yaml
    description: A minimal Azure Native Pulumi YAML program
    
    resources:
      # Create an Azure Resource Group
      resourceGroup:
        type: azure-native:resources:ResourceGroup
      # Create an Azure Storage Account
      sa:
        type: azure-native:storage:StorageAccount
        properties:
          resourceGroupName: ${resourceGroup.name}
          sku:
            name: Standard_LRS
          kind: StorageV2
    
    outputs:
      # Export the storage account name
      storageAccountName: ${sa.name}
    

    The program declares an Azure Resource Group and Storage Account resources and exports the storage account’s name as a stack output. Notice that the storage account name is an output property that Azure assigns at deployment time. Now you’re ready for your first deployment!

      Neo just got smarter about infrastructure policy automation