Hello, I'm fairly experienced with Terraform but a...
# getting-started
Hello, I'm fairly experienced with Terraform but am diving into Pulumi for the first time and I'm getting tripped on the basics, I'm basically trying to write some inline pulumi config that will deploy an azure storage account container when a user clicks a button on the website:
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const config = new pulumi.Config();
const location = config.require("location");
const storageAccountName = config.require("storageAccountName");
const storageContainerName = config.require("storageContainerName");
const resourceGroupName = config.require("resourceGroupName");
const storage = azure.core.getResourceGroup({
    name: resourceGroupName,
    location: location,
const container = new azure.storage.Container("container", {
    name: storageContainerName,
    storageAccountName: storageAccountName,
    containerAccessType: "private",
export const containerId = container.id;
export const containerResourceId = container.resourceManagerId;
This typescript code snippet was generated using tf2pulumi and I"m confuse about two things: • How do I add provider configuration to this to tell Pulumi which subscription I want to deploy the resource to? • How do I add backend configuraiton to this to tell Pulumi which backend I want to store my state file in (which in this case should be an Azure storage account) I've read through the documentation and can't seem to find the answer to these questions, any assistance would be greatly appreciated
Hi @modern-branch-92818 — for the provider configuration question, did you happen to find this page? https://www.pulumi.com/registry/packages/azure/installation-configuration/
It explains generally the options for configuring the Azure Classic provider.
For the second one, you can specify the backend with
pulumi stack init
— let me see if I can find the best doc for that
Ah, I missed the part right at the bottom for the
new azure.Provider
construct, I think that answers my question regarding the provider configuration
or actually, i misspoke — it’s
pulumi login
for the backend
Under Logging In, you’ll find a link to the section on using Azure Blob Storage.
yup so
pulumi login
is the cli tool to use for configuring the backend but can this not be defined inline?
Ah, I don’t think it can be defined in the program itself, no — others may correct me on that, but to the best of my knowledge the backend is configured outside the program.
I got the azure blob storage backend working with that cli tool yesterday but if I'm deploying this with my applicaiton i'm not going to be there to run
pulumi login
on the directory, so what's the usual expectation of how you initialise the pulumi backend for an unattended, inline function like that
APologies for any confusion, I'm not a developer so I'm probably missing something really obvious
Not at all, happy to help. It sounds like what you’re trying to build would maybe be better served with the Automation API, which is made to be embedded into application code. Let me see if I can find a doc that can help you with this.
Here’s a guide to getting started with Automation API: https://www.pulumi.com/docs/guides/automation-api/getting-started-automation-api
I believe the way to do this, though, would still be to run
pulumi login
— you’d just run it as part of your application startup. So for example, if your app were running as a Node.js process on an Azure VM, and your startup script were something like
node index.js
, you’d just add a line before that
call to run
pulumi login azblob://...
first, and Automation API (running in your application) would use that as its configured backend.
Alright, yeah so I was basically hoping to make use of the Automation API and I think I got a bit confused. So I can see pretty clearly in that page the provider configuration and the configuration of the pulumi stack for the provided deployment
Oh, I think I may have figured it out
On this page: https://www.pulumi.com/docs/intro/concepts/state/#logging-in it specifies setting the
environment variable, so for Azure blob you set that to azblob://mycontainer and seet the
environment variables for the automation API to pick up on?
or as the startup command I guess amkes sense too
This basically answers my question
Awesome, glad you’re all set. I’ll make a note to get this added to the docs as well.