InMemoryCloudMetadataProvider Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A ready-made, mutable ICloudMetadataProvider that a caller populates at startup, with an optional fallback provider for hosts it does not itself know about.
public sealed class InMemoryCloudMetadataProvider : Microsoft.Identity.Abstractions.ICloudMetadataProvider
type InMemoryCloudMetadataProvider = class
interface ICloudMetadataProvider
Public NotInheritable Class InMemoryCloudMetadataProvider
Implements ICloudMetadataProvider
- Inheritance
-
InMemoryCloudMetadataProvider
- Implements
Examples
// Inject a brand-new cloud (or adjust an existing one — same call, this provider wins per key):
ICloudMetadataProvider provider = new InMemoryCloudMetadataProvider()
.AddOrUpdate("login.mynewcloud.example", new Dictionary<string, string>
{
[CloudMetadataKeyNames.FederatedCredentialAudience] = "api://AzureADTokenExchangeMyCloud",
});
services.AddSingleton<ICloudMetadataProvider>(provider);
Remarks
This is the type customers instantiate directly when they need to inject a new cloud, or adjust an existing one, without implementing ICloudMetadataProvider by hand.
Like the rest of the identity SDK configuration surface, this provider follows a configure-then-read model: populate it via AddOrUpdate(String, IReadOnlyDictionary<String,String>) while composing your app (typically before registering it as a singleton), then treat it as read-only. The AddOrUpdate mutators are not safe to call concurrently with reads or with each other; GetByAuthorityHost(String) is safe for concurrent reads once population is complete.
Resolution layers the registered values over the optional fallback provider per key: a key registered here wins, a key not registered here falls back to the same host in the fallback, and a host unknown to both resolves to null. This per-key merge lets a caller override a single value for a cloud (for example one cloud's audience) while inheriting the rest of that cloud's metadata from the fallback, instead of re-declaring every key.
Constructors
| Name | Description |
|---|---|
| InMemoryCloudMetadataProvider(ICloudMetadataProvider) |
Initializes a new instance of the InMemoryCloudMetadataProvider class. |
Methods
| Name | Description |
|---|---|
| AddOrUpdate(String, IReadOnlyDictionary<String,String>) |
Adds or updates the metadata for the cloud identified by |
| AddOrUpdate(String, String, String) |
Adds or updates a single cloud-specific value for an authority host, merged per key over any values already registered for that host (and, at resolution time, over the fallback). Use this to adjust or add one value for a cloud while leaving its other values as-is. |
| GetByAuthorityHost(String) |
Gets the cloud-specific metadata for the cloud that owns |