private Azure(RestClient restClient, string subscriptionId, string tenantId, IAuthenticated authenticated) { resourceManager = ResourceManager.Fluent.ResourceManager.Authenticate(restClient).WithSubscription(subscriptionId); storageManager = StorageManager.Authenticate(restClient, subscriptionId); computeManager = ComputeManager.Authenticate(restClient, subscriptionId); networkManager = NetworkManager.Authenticate(restClient, subscriptionId); batchManager = BatchManager.Authenticate(restClient, subscriptionId); keyVaultManager = KeyVaultManager.Authenticate(restClient, subscriptionId, tenantId); trafficManager = TrafficManager.Fluent.TrafficManager.Authenticate(restClient, subscriptionId); dnsZoneManager = DnsZoneManager.Authenticate(restClient, subscriptionId); sqlManager = SqlManager.Authenticate(restClient, subscriptionId); redisManager = RedisManager.Authenticate(restClient, subscriptionId); cdnManager = CdnManager.Authenticate(restClient, subscriptionId); appServiceManager = AppServiceManager.Authenticate(restClient, subscriptionId, tenantId); searchManager = SearchManager.Authenticate(restClient, subscriptionId); serviceBusManager = ServiceBusManager.Authenticate(restClient, subscriptionId); containerInstanceManager = ContainerInstanceManager.Authenticate(restClient, subscriptionId); registryManager = RegistryManager.Authenticate(restClient, subscriptionId); containerServiceManager = ContainerServiceManager.Authenticate(restClient, subscriptionId); cosmosDBManager = CosmosDBManager.Authenticate(restClient, subscriptionId); authorizationManager = AuthorizationManager.Authenticate(restClient, subscriptionId); msiManager = MsiManager.Authenticate(restClient, subscriptionId); batchAIManager = BatchAIManager.Authenticate(restClient, subscriptionId); monitorManager = MonitorManager.Authenticate(restClient, subscriptionId); eventHubManager = EventHubManager.Authenticate(restClient, subscriptionId); SubscriptionId = subscriptionId; this.authenticated = authenticated; }
private async Task CreateVaultAsync(IResourceGroup resourceGroup, string certificateAuthorityPrincipalId) { var vault = await KeyVaultManager .Authenticate(_azureCredentials, _configuration.SubscriptionId) .Vaults .Define(_configuration.ResourceNamePrefix + "Vault") .WithRegion(_configuration.RegionName) .WithExistingResourceGroup(resourceGroup) .DefineAccessPolicy() .ForObjectId(_currentUserObjectId) .AllowCertificatePermissions(CertificatePermissions.List, CertificatePermissions.Get, CertificatePermissions.Import, CertificatePermissions.Create, CertificatePermissions.Update, CertificatePermissions.Delete) .AllowKeyPermissions(KeyPermissions.Sign) // This is required for local testing & debugging. Would remove for production. .Attach() .DefineAccessPolicy() .ForObjectId(certificateAuthorityPrincipalId) .AllowKeyPermissions(KeyPermissions.Sign) .AllowCertificatePermissions(CertificatePermissions.Get) .Attach() .CreateAsync(); Console.WriteLine($"Successfully created or updated key vault '{vault.Name}'"); }