Skip to content

Add TryBindConfiguration and IServiceCollection.RegisterAzureStorage overloads#57

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-trybindconfiguration-registerazurestorage-meth
Draft

Add TryBindConfiguration and IServiceCollection.RegisterAzureStorage overloads#57
Copilot wants to merge 2 commits into
mainfrom
copilot/add-trybindconfiguration-registerazurestorage-meth

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

Adds optional-binding and direct-service-collection variants to improve flexibility in test hosts, Worker Services, and scenarios where configuration sections may be absent.

TryBindConfiguration (MDev.Dotnet.AspNetCore)

Silent no-op variants of BindConfiguration — use GetSection + Exists() instead of GetRequiredSection, so they never throw when a section is missing. Four overloads added across both IHostApplicationBuilder and IServiceCollection:

// Does not throw if "FeatureX" is absent
builder.TryBindConfiguration<FeatureXSettings>("FeatureX");
builder.TryBindConfiguration<FeatureXSettings>(out var settings, "FeatureX");

services.TryBindConfiguration<FeatureXSettings>(configuration, "FeatureX");
services.TryBindConfiguration<FeatureXSettings>(configuration, out var settings, "FeatureX");

IServiceCollection.RegisterAzureStorage (MDev.Dotnet.Azure.StorageAccount)

New IServiceCollection overload mirroring the existing RegisterCosmosDb(IServiceCollection, IConfiguration, TokenCredential) pattern. The IHostApplicationBuilder variant now delegates to it:

// Usable without IHostApplicationBuilder (test hosts, Worker Services, etc.)
services.RegisterAzureStorage(configuration, new DefaultAzureCredential());

Copilot AI changed the title [WIP] Add TryBindConfiguration and RegisterAzureStorage methods Add TryBindConfiguration and IServiceCollection.RegisterAzureStorage overloads Apr 22, 2026
Copilot AI requested a review from mathieumack April 22, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve API: Add TryBindConfiguration and RegisterAzureStorage methods

2 participants