[FEATURE REQ] KeyVaultKeyIdentifier.TryParse
See original GitHub issueLibrary or service name. Azure.Security.KeyVault.Keys
Is your feature request related to a problem? Please describe. If I develop an application that takes user input that should be a key vault key URI I have to write the following code to validate it is a Key Vault URI.
try
{
identifier = new KeyVaultKeyIdentifier(id);
}
catch (ArgumentException)
{
// Invalid id
}
Ideally I would like to write
if (KeyVaultKeyIdentifier.TryParse(id, out KeyVaultKeyIdentifier identifier))
{
// use it
}
else
{
// Return error
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Quickstart: Azure Key Vault secret client library for JavaScript
Learn how to create, retrieve, and delete secrets from an Azure key vault using the JavaScript client library.
Read more >Handling KeyVault secret rotation changes utilized by an ...
This sample showcases one way to handle when a KeyVault secret used by your Azure Function is "rolled" or updated as part of...
Read more >Can't read value from Azure Key Vault
As described in the article, I'm using Managed Service Identity (MSI) but looks like I'm unable to read values from Key Vault.
Read more >Securing Web Application Secrets Through Azure Key Vault
Key Vault can be used to store the cryptographic secrets and keys such as authentication keys, storage account keys, data encryption keys, ...
Read more >How To Authorize Your Key Vault Secrets To Serverless ...
In this article, we will learn how to authorize our Azure Function to access Key Vault secrets.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The URI is not parsed. It is a URI, yes, but not necessarily a valid Key Vault URI. That’s why I had
KeyVaultSecretIdentifier.TryParse
originally. As @tg-msft pointed out from the .NET Framework Guidelines,The point of this struct was to parse a URI as a valid Key Vault (or Managed HSM) URI. I agree that we need a
TryParse
.I am not totally opposed to digging deeper here and possibly solving a problem, but:
It’s not really parsing. The URI is already parsed when it’s passed to the ctor. The issue seems to be that some users (e.g. @jimmyca15) do not like exceptions for invalid arguments. I totally understand issues with C# exception handling (I am myself not a big fan), and I talked with the C# team many times about it, but don’t think TryParse was intended for that. In .NET, we throw exceptions for invalid arguments.
.NET guidelines specifically state that Try methods should not be added because we don’t like exceptions. Try methods are performance optimizations, and so if you add them you need to show that performance is a problem (not in microbenchmarks).
If we started to add Try methods to all places where we don’t like exceptions, we would end up with every BCL API duplicated (try and non-try variants).
@MadsTorgersen, @jaredpar, if would be nice to have try expressions in the language, just like we planned in M# 😃
see “int value1 = try Foo() else 42;” @ http://joeduffyblog.com/2016/02/07/the-error-model/