public async Task DeleteDatasourceCredential() { MetricsAdvisorAdministrationClient adminClient = GetMetricsAdvisorAdministrationClient(); var credentialName = Recording.GenerateAlphaNumericId("credential"); var credentialToCreate = new ServicePrincipalDatasourceCredential(credentialName, "clientId", "clientSecret", "tenantId"); string credentialId = null; try { DatasourceCredential createdCredential = await adminClient.CreateDatasourceCredentialAsync(credentialToCreate); credentialId = createdCredential.Id; Assert.That(credentialId, Is.Not.Null.And.Not.Empty); } finally { if (credentialId != null) { await adminClient.DeleteDatasourceCredentialAsync(credentialId); var errorCause = "credentialId is invalid"; Assert.That(async() => await adminClient.GetDatasourceCredentialAsync(credentialId), Throws.InstanceOf <RequestFailedException>().With.Message.Contains(errorCause)); } } }
/// <summary> /// Deletes the datasource credential this instance is associated with. /// </summary> public async ValueTask DisposeAsync() => await _adminClient.DeleteDatasourceCredentialAsync(Credential.Id);