Skip to main content

BapEnvironmentService

  • Namespace: PPDS.Auth.Discovery
  • Assembly: PPDS.Auth
  • Kind: Class
  • Implements: IEnvironmentDiscoveryService, IDisposable

Summary​

Discovers Dataverse environments via the BAP (Business Application Platform) admin API. Suitable for service principal authentication where Global Discovery is not available.

Members​

Constructors​

BapEnvironmentService(HttpClient httpClient, string bapApiUrl, Func<CancellationToken, Task<string>> tokenProvider)​

BapEnvironmentService(HttpClient httpClient, string bapApiUrl, Func<CancellationToken, Task<string>> tokenProvider)

Creates a new BapEnvironmentService.

  • Param httpClient: The HTTP client to use for API calls.

  • Param bapApiUrl: The BAP API base URL (e.g., https://api.bap.microsoft.com).

  • Param tokenProvider: A function that acquires a bearer token for the BAP API.

Methods​

DiscoverEnvironmentsAsync​

Task<IReadOnlyList<DiscoveredEnvironment>> DiscoverEnvironmentsAsync(CancellationToken cancellationToken)

Discovers all environments accessible to the authenticated principal.

  • Param cancellationToken: Cancellation token.

  • Returns: Collection of discovered environments.

Dispose​

void Dispose()

(inherited from System.IDisposable.Dispose)

FromProfileAsync​

Task<BapEnvironmentService> FromProfileAsync(AuthProfile profile, ISecureCredentialStore credentialStore, CancellationToken cancellationToken)

Creates a BapEnvironmentService from an auth profile using MSAL confidential client.

  • Param profile: The auth profile (must use ClientSecret, CertificateFile, or CertificateStore).

  • Param credentialStore: Optional credential store for retrieving stored secrets.

  • Param cancellationToken: Cancellation token for the credential store lookup.

  • Returns: A new BapEnvironmentService instance. Caller must dispose.

SupportsAuthMethod​

bool SupportsAuthMethod(AuthMethod authMethod)

Returns whether the given auth method is supported by BAP discovery.