Author : MD TAREQ HASSAN | Updated : 2021/10/29

To Use Azure Blob Container as Backend

Following environment variables must be set (in local machine or in Azure DevOps Pipeline Agent VM)

Best practice for Azure DevOps Pipeline

To Use Azure KeyVault Key for Pulumi Secrets

Following environment variables must be set (in local machine or in Azure DevOps Pipeline Agent VM)

In local machine, you can set ``

**Alternatively, set environment variable “AZURE_KEYVAULT_AUTH_VIA_CLI” to true

To Deploy Stack To Target Subscription

Pulumi CLI can authenticate to Azure using either of followings

Making tokens available to Pulumi when using Service Principal Set environment variables

Or set configuration secrets

pulumi config set azure:clientId <clientID> --secret
pulumi config set azure:clientSecret <clientSecret> --secret
pulumi config set azure:tenantId <tenantID> --secret
pulumi config set azure:subscriptionId <subscriptionId> --secret

Getting Environment Variable Value in Code

//
// TenantId is saved as Environment Variable in either
// - Local Machine
// - Azure DevOps Pipeline Agent VM
//
const string EnvVarKeyTenantId = "AZURE_TENANT_ID";

var tenantId = Environment.GetEnvironmentVariable(EnvVarKeyTenantId, EnvironmentVariableTarget.Process); # .Machine for windows only, .User might not work