https://pulumi.com logo
#python
Title
# python
h

helpful-rain-41425

01/21/2021, 2:32 AM
Hi all, new to Pulumi & not that great at Python. I am trying to build a few things using azure-nextgen provider and I am having trouble with creating a storage account, then retrieving its account key:
Copy code
import pulumi
from pulumi_azure_nextgen.containerinstance import latest as containerinstance
from pulumi_azure_nextgen.resources import latest as resources
from pulumi_azure_nextgen.storage import latest as storage

app_name = "tigstack"

resource_group = resources.ResourceGroup("resourceGroup",
    resource_group_name="rg-syd-dev-{0}".format(app_name),
    location="australiaeast")

account = storage.StorageAccount("storageAccount",
    account_name="grafana",
    resource_group_name=resource_group.name,
    location=resource_group.location,
    sku=storage.SkuArgs(
        name="Standard_LRS"
    ),
    kind="StorageV2")

file_share = storage.FileShare("smbFileShare",
    account_name=account.name,
    enabled_protocols="SMB",
    resource_group_name=resource_group.name,
    share_name="tigstack")

storageAccountKeys = pulumi.Output.all(resource_group.name, account.name).apply(
        lambda args: storage.list_storage_account_keys(args))
I came up with that where I want to refer to storageAccountKeys later in the code but it doesn't seem to work - i think I don't understand the output.all that well
w

witty-candle-66007

01/21/2021, 1:00 PM
I think the call to
list_storage_account_keys
needs to specify the property names and not just the values. So something like this:
Copy code
storageAccountKeys = pulumi.Output.all(resource_group.name, account.name).apply(
        lambda args: storage.list_storage_account_keys(resource_group_name: args[0], account_name: args[1]))
h

helpful-rain-41425

01/21/2021, 7:45 PM
So close and yet so far away. Thank you Mitch that works!!