---
title: "Azure TypeScript Starter"
description: "A minimal Azure Native TypeScript Pulumi program"
url: "https://www.pulumi.com/dev/templates/azure-typescript/"
image: "https://www.pulumi.com/assets/og/dev/templates/azure-typescript.png"
---

# Azure TypeScript Starter

A minimal Azure Native TypeScript Pulumi program

## Before you begin

For this walkthrough, you'll need:

- [x] The [Pulumi CLI](https://www.pulumi.com/docs/install/)
- [x] An [Azure account](https://azure.microsoft.com/free)
- [x] The [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) (optional, but recommended and used in this guide)
- [x] Pulumi [configured with your Azure credentials](https://www.pulumi.com/registry/packages/azure-native/installation-configuration#credentials)
- [x] Permission to manage Azure Storage
- [x] A current version of [Node.js](https://nodejs.org/en/download) and [npm](https://www.npmjs.com/package/npm) installed locally

## Create a new project

This starter creates an Azure resource group with a storage account in it and exports the storage account's name.

```bash
mkdir my-project; cd my-project
pulumi new azure-typescript
```

The `pulumi new` command walks you through creating and configuring the new project and stack. A [stack](https://www.pulumi.com/docs/iac/concepts/stacks/) is an instance of a project, and you can have many of them (`dev`, `staging`, `prod`), each with its own [configuration](https://www.pulumi.com/docs/iac/concepts/config/) settings. Depending on the language, you may also be asked for your preferred package manager or toolchain.

The template also asks for the Azure `location` you'd like to deploy into:

| Key | Description | Default |
| --- | --- | --- |
| `azure-native:location` | The Azure location to use | `WestUS2` |

You can change values like these later with `pulumi config set`:

```bash
pulumi config set azure-native:location <value>
```

## Review the code

When setup completes, you'll see a few files:

- `Pulumi.yaml` contains the project name and the language it's written in.
- `Pulumi.dev.yaml` contains the `dev` stack's settings, including the values you just entered.
- `index.ts` contains the program code that declares your cloud resources.

Take a moment to open them up and have a look. Here's what's in `index.ts`:

```typescript title="index.ts"
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 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;
```

## Deploy the project

Deploy with [`pulumi up`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_up). It starts with a preview of what it's about to create and asks before it changes anything. Choose `yes` to deploy.

Pulumi adds a random suffix to most resource names, so the storage account `sa` gets a name like `sa8deefa78`. This is [autonaming](https://www.pulumi.com/docs/iac/concepts/resources/names/#autonaming). It lets you deploy the same program to more than one stack, and lets Pulumi create a replacement before it deletes the old resource, without names colliding.

```bash
$ pulumi up
```

When it finishes, Pulumi prints the stack's outputs, values it only knows once the resources exist. This program exports the storage account's name. Read it any time with `pulumi stack output <name>`, or pass it to another command. This one prints the account's blob endpoint:

```bash
$ az storage account show --name $(pulumi stack output storageAccountName) --query primaryEndpoints.blob --output tsv
```

**Need help?**

If `pulumi up` asks you to run `az login`, or says your sign-in has expired, sign in again:

```bash
$ az login
```

Still stuck? [Let us know](https://github.com/pulumi/docs/issues/new).

## Customize the project

Put a file in the storage account. In `index.ts`, add this below the storage account:

```typescript
const container = new storage.BlobContainer("container", {
    resourceGroupName: resourceGroup.name,
    accountName: storageAccount.name,
});

new storage.Blob("hello", {
    resourceGroupName: resourceGroup.name,
    accountName: storageAccount.name,
    containerName: container.name,
    blobName: "hello.txt",
    source: new pulumi.asset.StringAsset("Hello, Pulumi!"),
});

export const containerName = container.name;
```

Deploy again. The preview shows a container and a file to create:

```bash
$ pulumi up
```

Then read the file back from the storage account. It prints `Hello, Pulumi!`:

```bash
$ az storage blob download --account-name $(pulumi stack output storageAccountName) --container-name $(pulumi stack output containerName) --name hello.txt --auth-mode key --only-show-errors --no-progress
```

To see what else you can add, browse the [Azure Native provider](https://www.pulumi.com/registry/packages/azure-native/) in the Pulumi Registry.

## Cleaning up

You can destroy the stack and all of its infrastructure with [`pulumi destroy`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_destroy), then remove the stack with [`pulumi stack rm`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_stack_rm):

```bash
$ pulumi destroy
$ pulumi stack rm
```

## Links

- Deploy with Pulumi: https://app.pulumi.com/new?template=https%3A%2F%2Fgithub.com%2Fpulumi%2Ftemplates%2Ftree%2Fmaster%2Fazure-typescript
- Source on GitHub: https://github.com/pulumi/templates/tree/master/azure-typescript
