Pulumi Azure Native
Pulumi Azure Native is a Pulumi provider that enables users to manage Azure resources directly from the Azure Resource Manager (ARM) API. It offers complete coverage of Azure resources and is updated frequently, often with new features and schema changes. The current version is 3.16.0, with releases occurring roughly every 2-4 weeks.
Warnings
- breaking Pulumi Azure Native frequently introduces breaking changes due to its direct mapping to the evolving Azure Resource Manager (ARM) API. These changes often involve the removal, renaming, or type modification of resource input properties and output properties.
- gotcha Pulumi uses logical resource names for its state, which are distinct from the physical resource names deployed in Azure. The first argument to a resource constructor is the logical name, while an explicit property (e.g., `resource_group_name`) sets the actual Azure resource name.
- gotcha Resource properties are often Pulumi 'Output' types (futures) which resolve asynchronously. Attempting to use a raw Output object as a string or a direct value will result in unexpected behavior.
- gotcha Pulumi Azure Native relies on pre-configured Azure authentication. It does not manage your Azure credentials directly, but rather uses credentials available to the underlying Azure SDK (typically via Azure CLI login or environment variables).
Install
-
pip install pulumi-azure-native
Imports
- ResourceGroup
from pulumi_azure_native import resources
- StorageAccount
from pulumi_azure_native import storage
- SkuArgs
from pulumi_azure_native.storage import SkuArgs
Quickstart
import pulumi
import pulumi_azure_native as azure_native
import os
# Pulumi requires Azure credentials to be configured (e.g., via `az login` or environment variables).
# The Azure location is usually set via `pulumi config set azure-native:location eastus`.
# Define a unique suffix for resource names to avoid conflicts
# In a real project, this might come from pulumi.StackReference or config.
stack_suffix = os.environ.get("PULUMI_STACK_SUFFIX", "dev").lower()
# Create an Azure Resource Group
resource_group = azure_native.resources.ResourceGroup("my-resource-group",
resource_group_name=f"my-pulumi-rg-{stack_suffix}",
location="EastUS") # Location often configured globally via 'pulumi config set azure-native:location'
# Create an Azure Storage Account
# Note: Storage account names must be globally unique and lowercase.
storage_account = azure_native.storage.StorageAccount("mystorageaccount",
resource_group_name=resource_group.name, # Pulumi automatically unwraps output properties
account_name=f"mypulumiaccount{stack_suffix}123",
location=resource_group.location,
sku=azure_native.storage.SkuArgs(name="Standard_LRS"),
kind="StorageV2")
pulumi.export("resource_group_name", resource_group.name)
pulumi.export("storage_account_name", storage_account.name)
pulumi.export("storage_account_primary_blob_endpoint", storage_account.primary_endpoints.apply(lambda endpoints: endpoints.blob))