Hello guys, good afternoon! I’m trying to get the ...
# getting-started
e
Hello guys, good afternoon! I’m trying to get the primary_access_key from a storage account that was created with azure_native but I’m completely lost. I tried to use the “list_storage_account” to see it but it returns the entire output and I don’t know how to access only to the primary key value since it can’t be accessed through an index. Anybody knows how to access to the primary_access_key from that azure_native storage account?
Copy code
Note:
This is the output I get from list_storage_account

Outputs:
  + name    : {
      + keys: [
      +     [0]: {
              + creation_time: "2021-08-06T00:13:40.4886860Z"
              + key_name     : "key1"
              + permissions  : "FULL"
              + value        : "xxxxxxxxxxxxx"
            }
      +     [1]: {
              + creation_time: "2021-08-06T00:13:40.4886860Z"
              + key_name     : "key2"
              + permissions  : "FULL"
              + value        : "xxxxxxxxxxxxxxx"
            }
        ]
    }
b
I doh't see a
list_storage_account
call? I see
list_storage_account_keys
?
you also may want to redact your values
‼️ 1
can you share the code you have so far?
e
Thanks for the reply! This is how I list the keys:
Copy code
list_storage_account = azure_native.storage.list_storage_account_keys(
    account_name=scrubout.name,
    resource_group_name=resource_group.name   
)
b
okay, what do you want to do with the values now you're retirved them? pass them to another resource?
e
I just need the primary storage key but I get the entire output, so I don’t know if theres a method to get only the primary access key, the first one
Copy code
The storage account was created using azure_native.storage.StorageAccount()
b
i assume the primary key is the first result in the array, which you'll need to use an
apply
to access
it looks like the arm API doesn't have primary key for storage account keys? I can't find it in the spec
e
Yes, it is the first result in the array but I can’t access to it, it is just not “suscriptable”.
Copy code
pulumi.export("name", list_storage_account[0])
    TypeError: 'AwaitableListStorageAccountKeysResult' object is not subscriptable
b
Yes because as I just said, you need to use an apply
e
Ok, I’ll cheeck the C# example you provided 👍