Skip to content
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

KeyVault reference in AzureAppConfiguration with Azure-Native #3955

Open
Mewriick opened this issue Feb 17, 2025 · 5 comments
Open

KeyVault reference in AzureAppConfiguration with Azure-Native #3955

Mewriick opened this issue Feb 17, 2025 · 5 comments
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@Mewriick
Copy link

Hello,

I have problem with adding from C# key vault reference into azure app config. I followed #1034 (comment) and use this code

new KeyValue(<name>,
	new KeyValueArgs {
		ResourceGroupName = configurationStoreResourceGroupName,
		ConfigStoreName = configurationStoreName,
		KeyValueName =<value-name>,
		Value = $"{{\"uri\":\"https://<vault-name>.vault.azure.net/secrets/<key-vault-sercte-name>\"}}",
		ContentType = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"
	}
);

unfortunately I received this error

--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE UNAVAILABLE
--------------------------------------------------------------------------------
Response contained no body
--------------------------------------------------------------------------------

I have correctly setted permissions for KeyVault and also for AzureAppConfiguration (App Configuration Contributor)

Can you plase advise what is wrong?

@pulumi-bot pulumi-bot added the needs-triage Needs attention from the triage team label Feb 17, 2025
@jbrezina
Copy link

The problem is when you use / in the key name.
For example the key MyApp/My Option results in the following in the PUT URL
...keyValues/MyApp/My Option
Notice, that api version is missing in the URL.

We tried to URL encode the / in the key name to %2F - MyApp%2FMy Option which resulted in the PUT URL
...keyValues/MyApp%252FMy%20Option?api-version=2024-05-01
Notice the % is encoded into %25. So when we add % into the key name, some encoding happens, but not in case there is only /. In my opinion you should always URL encode the key name.

@rquitales
Copy link
Member

Thanks for the assist here @jbrezina. @Mewriick please let us know if this resolves your issue. Thanks.

@rquitales rquitales added kind/bug Some behavior is incorrect or out of spec awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Feb 19, 2025
@jbrezina
Copy link

This is a bug on the Pulumi side. Pulumi has to correctly encode the characters in the key name so it can be passed in the Azure REST API URL.

@pulumi-bot pulumi-bot added needs-triage Needs attention from the triage team and removed awaiting-feedback Blocked on input from the author labels Feb 19, 2025
@rquitales rquitales removed the needs-triage Needs attention from the triage team label Feb 19, 2025
@rquitales
Copy link
Member

Thanks for the call out. Yes, encoding the key name would be helpful here. I'll add this to our backlog and flag this to my team as well.

@rquitales
Copy link
Member

Adding this code snippet here as it may help with a fix:

urlValues := MapToValues(queryParams)
// URL-unescape each value before encoding the URL (which encodes all values). Presumably, this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

4 participants