Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam AZ-204 topic 4 question 15 discussion

Actual exam question from Microsoft's AZ-204
Question #: 15
Topic #: 4
[All AZ-204 Questions]

DRAG DROP -
You are developing an application. You have an Azure user account that has access to two subscriptions.
You need to retrieve a storage account key secret from Azure Key Vault.
In which order should you arrange the PowerShell commands to develop the solution? To answer, move all commands from the list of commands to the answer area and arrange them in the correct order.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Step 1: Get-AzSubscription -
If you have multiple subscriptions, you might have to specify the one that was used to create your key vault. Enter the following to see the subscriptions for your account:

Get-AzSubscription -
Step 2: Set-AzContext -SubscriptionId
To specify the subscription that's associated with the key vault you'll be logging, enter:
Set-AzContext -SubscriptionId <subscriptionID>

Step 3: Get-AzStorageAccountKey -
You must get that storage account key.
Step 4: $secretvalue = ConvertTo-SecureString <storageAccountKey> -AsPlainText -Force
Set-AzKeyVaultSecret -VaultName <vaultName> -Name <secretName> -SecretValue $secretvalue
After retrieving your secret (in this case, your storage account key), you must convert that key to a secure string, and then create a secret with that value in your key vault.

Step 5: Get-AzKeyVaultSecret -
Next, get the URI for the secret you created. You'll need this URI in a later step to call the key vault and retrieve your secret. Run the following PowerShell command and make note of the ID value, which is the secret's URI:
Get-AzKeyVaultSecret ג€"VaultName <vaultName>
Reference:
https://docs.microsoft.com/bs-latn-ba/Azure/key-vault/key-vault-key-rotation-log-monitoring

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
AnonymousJhb
Highly Voted 3 years, 6 months ago
Answer looks correct
upvoted 56 times
Bear_Polar
1 year, 7 months ago
Correct! Reference: https://learn.microsoft.com/bs-latn-ba/azure/key-vault/secrets/tutorial-rotation-dual?tabs=azurepowershell#add-the-storage-account-access-keys-to-key-vault-secrets
upvoted 3 times
...
...
Frakandel
Highly Voted 3 years, 1 month ago
Question does not explain where the variables come from... Assuming I set the variables myself (as a "side effect" of the command), the solution below does make sense: 1. Get-AzSubscription 2. Set-AzContext –SubscriptionId $subscriptionID 3. Get-AzKeyVaultSecret –VaultName $vaultName 4. Get-AzStorageAccountKey –ResourceGroupName $resGroup –Name $storAcct 5. $secretvalue = ConvertTo-SecureString $storAcctkey –AsPlainText –Force Set-AzKeyVaultSecret –VaultName $vaultName –Name $secretName –SecretValue $secretvalue
upvoted 42 times
...
p2006
Most Recent 9 months, 1 week ago
https://learn.microsoft.com/en-us/azure/key-vault/secrets/tutorial-rotation-dual?tabs=azurepowershell#add-storage-account-access-key-to-key-vault-secrets
upvoted 4 times
...
suku555
2 years, 1 month ago
Given Answer is correct only. "Get-AzKeyVaultSecret -VaultName $vaultName" is just to make sure that we stored the key in vault (verification/double check). Placing this command anywhere else in the order does not make any sense.
upvoted 3 times
suku555
2 years, 1 month ago
Also the main purpose of "Get-AzKeyVaultSecret -VaultName $vaultName" at last is for the future usage..
upvoted 2 times
...
...
Azprep
2 years, 2 months ago
Given answer us correct
upvoted 2 times
...
MiraA
2 years, 9 months ago
I believe the assignment wants to select a proper subscription, then to retrieve the storage account key, then to store this key into the KeyVault and finally to check the secret was inserted properly. So: 1. Get-AzSubscription ($subscriptionID = (...).SubscriptionName) 2. Set-AzContext 3. Get-AzStorageAccountKey ($storAcctkey = "(...)[0].Value") 4. ConvertTo-SecureString, Set-AzKeyVaultSecret 5. Get-AzKeyVaultSecret (list the secrets stored in the KeyVault - check only)
upvoted 30 times
NPE_
7 months, 3 weeks ago
Thank you so much for the explanation!!! I was totally lost after seeing the answer.
upvoted 1 times
...
...
ning
2 years, 10 months ago
Does the question miss some part? Why it has to save the key before retrieval? No where in the question mentioned that ... First two Get-AzSubscription Set-AzContext –SubscriptionId $subscriptionID are absolutely correct, since there are two subscriptions, you have to point to the correct one ... but I am confused with 3, 4, 5 steps, what are those?
upvoted 12 times
...
glam
3 years, 1 month ago
correct.
upvoted 3 times
...
sushikid112
3 years, 5 months ago
Agree with some people saying the question and picture does not make sense. The question only says how to retrieve the secret from Key Vault. Based on the options, we also have to retrieve the value and insert it to Key Vault first. The question/picture lacks information based on what we have.
upvoted 9 times
...
Rodashar
3 years, 6 months ago
Is this question actually on the exam? Even the url provided to explain the answer says this code is meant to cycle the storage keys stored in the vault not retrieve a key from the vault. Either the question is wrong or the answer is wrong.
upvoted 6 times
...
Tealon
3 years, 6 months ago
I agree, the question does not match the options to give the answer. If the question was to store the account key to the key vault and then retrieve it from the key vault, the answer would be correct.
upvoted 5 times
iiiihhhh
3 years, 6 months ago
There is another discussion for this question: https://www.examtopics.com/discussions/microsoft/view/22272-exam-az-204-topic-3-question-5-discussion/
upvoted 2 times
...
...
iiiihhhh
3 years, 6 months ago
The question is: How to get secret from key vault, when there are two subscriptions available? Available components(in order of boxes): 1. converting $storageAcctkey to secure string and storing az secret with name $secretName 2. getting storage accout key from storage account (but without storing to variable $storageAcctkey) 3. setting subscription context for use in current session (https://docs.microsoft.com/en-us/powershell/module/az.accounts/set-azcontext?view=azps-5.1.0) 4. list secrets in the vault 5. list subscriptions available So for retrieving secret we (I think) need 5,3,4 and we need also SecureStringToBSTR (https://docs.microsoft.com/cs-cz/azure/key-vault/secrets/quick-create-powershell). However the question seems to require using all actions available. Is the question text really matching the picture?
upvoted 7 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
ex Want to SAVE BIG on Certification Exam Prep?
close
ex Unlock All Exams with ExamTopics Pro 75% Off
  • arrow Choose From 1000+ Exams
  • arrow Access to 10 Exams per Month
  • arrow PDF Format Available
  • arrow Inline Discussions
  • arrow No Captcha/Robot Checks
Limited Time Offer
Ends in