Unable to create secret on key vault

Bela Vista UK 0 Reputation points
2024-11-03T14:00:51.89+00:00

az keyvault secret set --vault-name "my key vault name" --name "my secret name" --value "the secret goes here"

(Forbidden) {"objectName":"my secret name","message":"Secret 'my secret name' was disallowed by policy.","policyIdentifiers":{"policyAssignment":{"name":"Enforce recommended guardrails for Azure Key Vault","id":"/providers/Microsoft.Management/managementGroups/alztest-platform/providers/Microsoft.Authorization/policyAssignments/Enforce-GR-KeyVault"},"policyDefinition":{"name":"Secrets should have the specified maximum validity period","id":"/providers/Microsoft.Authorization/policyDefinitions/342e8053-e12e-4c44-be01-c3c2f318400f"}}}

Code: Forbidden

Message: {"objectName":"my secret name","message":"Secret 'my secret name' was disallowed by policy.","policyIdentifiers":{"policyAssignment":{"name":"Enforce recommended guardrails for Azure Key Vault","id":"/providers/Microsoft.Management/managementGroups/alztest-platform/providers/Microsoft.Authorization/policyAssignments/Enforce-GR-KeyVault"},"policyDefinition":{"name":"Secrets should have the specified maximum validity period","id":"/providers/Microsoft.Authorization/policyDefinitions/342e8053-e12e-4c44-be01-c3c2f318400f"}}}

Inner error: {

"code": "ForbiddenByGovernancePolicy"

}

I just deleted the policy already...then waited for 30 minutes...then I attempted: az policy state trigger-scan

Then wait again..then attempted again

Nothing is actually working.

Any clue ?

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,451 questions
Azure | Azure Startups
{count} votes

1 answer

Sort by: Most helpful
  1. Raja Pothuraju 23,790 Reputation points Microsoft External Staff Moderator
    2024-11-03T20:08:19.3433333+00:00

    Hello @Bela Vista UK,

    Thank you for posting your query on Microsoft Q&A.

    Based on your description, it seems you are trying to set or update a secret in KeyVault using the AZ CLI command "az keyvault secret set --name MySecretName --vault-name MyKeyVault --value MyVault" but encountered an error stating, "Secret 'MySecretName' was disallowed by policy."

    To assist you further, could you confirm if you are able to set the secret directly from the Azure Portal?

    I have tested setting up a secret from both the Azure Portal and the AZ CLI command successfully. Given the error, it appears that an Azure Policy definition is being enforced on this operation: "providers/Microsoft.Authorization/policyDefinitions/342e8053-e12e-4c44-be01-c3c2f318400f".

    Please check if the Azure Policy with ID 342e8053-e12e-4c44-be01-c3c2f318400f is enabled, and review the available effects and default values configured for that policy. Adjusting these settings may resolve the restriction on setting the secret.

    Thanks,
    Raja Pothuraju.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.