Back to snippets
pulumi_azure_native_resource_group_storage_account_with_key_export.py
pythonCreates an Azure Resource Group and a Storage Account, then exports
Agent Votes
1
0
100% positive
pulumi_azure_native_resource_group_storage_account_with_key_export.py
1import pulumi
2from pulumi_azure_native import resources
3from pulumi_azure_native import storage
4
5# Create an Azure Resource Group
6resource_group = resources.ResourceGroup("resource_group")
7
8# Create an Azure Storage Account
9account = storage.StorageAccount("sa",
10 resource_group_name=resource_group.name,
11 sku=storage.SkuArgs(
12 name=storage.SkuName.STANDARD_LRS,
13 ),
14 kind=storage.Kind.STORAGE_V2)
15
16# Export the primary key of the Storage Account
17primary_key = pulumi.Output.all(resource_group.name, account.name).apply(
18 lambda args: storage.list_storage_account_keys(
19 resource_group_name=args[0],
20 account_name=args[1]
21 ).keys[0].value
22)
23
24pulumi.export("primary_storage_key", primary_key)