-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
az keyvault list does not show newly created key vault #23428
Comments
Please note, I upgraded to azure-cli 2.39 and the same problem occurred:
|
@evelyn-ys for awareness |
This could be server delay. Need Keyvault service or ARM service check. |
Thank you for your feedback. This has been routed to the support team for assistance. |
@mmckechney Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update. |
@mmckechney I was able to run the below command to create a KV and was able to list it. See below
I have tried with both AzCLI 2.38.0 and using 2.39.0 version and both worked. If the above commands doesn't help, Please run the list command again with |
@navba-MSFT - this works for me today. I wonder if there was some latency in Azure yesterday unrelated to the CLI. In any case, I will close this issue. Thanks. |
In our org, we are hitting this quite frequently. We have a pipeline for putting up dev clusters that creates keyvaults in one step and later verifies existence with We create the keyvault (into an also newly created resourceGroup) with: Later we run and see exactly the behavior that @mmckechney describes: Occasionally, In out case, using |
@navba-MSFT what is the proper protocol to re-open this ticket? I thought maybe i'd ask instead of creating a dupe... Thanks! |
I have the same issue. I create new KeyVaults in a pipeline using: @tylercarper perhaps any luck to fix or workaround already? :) |
Reopening based on experience of @tylercarper and @rkisliak |
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @RandalliLama, @schaabs, @jlichwa. Issue DetailsThis is autogenerated. Please review and update as needed.Describe the bugaz keyvault list does not show newly created key vault Command Name Errors:
To Reproduce:Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
This gives an empty result: However, Expected BehaviorKey vault information should be shown Environment Summary
Additional Context
|
Adding Service team to provide pointers on this. @RandalliLama, @schaabs, @jlichwa Could you please look into this once you get a chance ? |
Any luck to check this? :) |
I can confirm. This is happening in our organization aswell. We are using Azure CLI Version 2.41.0. We have Azure Devops Pipelines and try to deploy KeyVaults and set policies on them directly afterwards. Two of my colleagues had this error multiple times on their machines aswell. We could not determine the reason. An DNS Cache Clear didn't help either. Once they executed It even happens randomly while the script is running and already set policies successfully. We have a script which accepts multiple policies at once and we loop over them and set policies on the keyvault. On the first policies it worked but stopped working afterwards. Once it stops working it won't start working again. We introduced retries in the script with delay between the retries. Up to a total of 10 retries with 2 seconds delay in between. When the Pipeline Job is rerun it works again (probably because another agent is used). This error is somehow bound to the machine for some duration of time. |
It can take some time until all key vaults list are propagated across regions. The only way to get Key Vault is to retrieve it directly or if list is needed you will need retry for time till vaults list is propagated. |
By "retrieve it directly" do you mean We have a script like that (simplified): param (
$KeyVault,
$SecretPersmissions
)
foreach ($secretPermission in $SecretPermissions)
{
for($try = 0; $try -le 10; $try++){
# Including some error handling which checks if the policy was set correctly (removed for brevity)
az keyvault set-policy `
--name $KeyVault `
--secret-permissions $secretPermission.Permissions `
--object-id $secretPermission.ObjectId
# Sleep 2 seconds on error, break from inner loop if successful
}
} Consider we have 10 Secret Permissions. The first three work perfektly fine but then we get the error "The Vault '$KeyVault' not found within subscription" and it does not go away within the 10 retries. And we can't wait half an hour for our pipeline to complete this one step. But this does not happen always. Only sometimes! We don't know why. When rerunning the pipeline step it usually just works. If the Why do we need to wait until its propagated if we could already set the key vault policies successfully? Also: We have the same problem on KeyVaults which were created way before. |
@MarioCakeDev Key Vault show is directly calling the vault created. The list is using cached list of vaults in ARM which takes a while to propagate across regions. We can't wait since we don't control of ARM service propagation of resources. In terms az keyvault set-policy that should not be related to listing vaults in subscription. @yonzhan can you check how set-policy is implemented it should call same rest api? It is likely different issue. On the other note you should like plan to move from access policies to RBAC (we are moving away from old legacy access policy model). |
I could narrow down the problem to the If I try to set the KeyVault Policy with the Azure CLI only based on the KeyVault name, I think this endpoint is called to find the KeyVault. This endpoint does not return the requested KeyVault. I don't know why it does not return the KeyVault. If I add the resource group to the command everything works again. I have wondered why the KeyVault can be found when I open the portal so I have looked into the network requests and it seems like the portal is using the |
@MarioCakeDev yes Portal is using that endpoint same as list which is trying to find vault (which can take some time to propagate0, but if you call key vault by name directly, it is calling Key Vault directly. If you use show with resourcegroup as parameter I see in debug that az cli is directly calling vault. I'm a bit lost how from listing the vault you are moving to Access Policy - how is that connected. Are you trying to create Access Policy after Vault is created - any reason to not do it in the same time? |
@MarioCakeDev to summarize based on questions above. The endpoint (https://management.azure.com/subscriptions/{subscriptionId}/resources) is used to list resources across regions, which is using ARM caching across regions, and it takes some time to propagate. With resource group and default subscription it can construct ARM resource it and call it directly and that is why it works. |
@jlichwa When I call I could use the
Because the KeyVault is one of the first resources which is created. After that the resources set their required access policies on the KeyVault themselfs. And at the current stage of our pipeline we cannot invert the dependencies. |
@MarioCakeDev there is no workaround in that case. You need to know resource uri to call key vault. The find operation it is ARM across all resources in Azure and with that it is caching the list in every region, so there is a delay. There is nothing CLI team can do here for you. |
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
This is autogenerated. Please review and update as needed.
Describe the bug
az keyvault list does not show newly created key vault
Command Name
az keyvault list
Errors:
empty list when the key vault should be listed
To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
az keyvault create -g {rg} -n {vault name}
az keyvault list -g {rg}
This gives an empty result:
[]
However,
show
does work and give the details of the key vault:az keyvault show -g {rg} -n {vault name}
Expected Behavior
Key vault information should be shown
Environment Summary
Additional Context
The text was updated successfully, but these errors were encountered: