public async Task CreateDBInClusterAsync(string databaseName, TimeSpan?softDeletePeriod, TimeSpan?hotCachePeriod = null) { try { var database = new ReadWriteDatabase( location: this.config.Global.Location, softDeletePeriod: softDeletePeriod, hotCachePeriod: hotCachePeriod); await this.client.Databases.CreateOrUpdateAsync( this.config.Global.ResourceGroup, this.config.Global.DataExplorer.Name, databaseName, database); } catch (CloudException e) { if (e.Body.Code == "ResourceNotFound") { throw new ResourceNotFoundException($"Error Creating kusto database {databaseName}"); } throw e; } }
public async Task DeleteDatabaseAsync(string databaseName) { ReadWriteDatabase result = null; try { result = await this.client.Databases.GetAsync( this.config.Global.ResourceGroup, this.config.Global.DataExplorer.Name, databaseName) as ReadWriteDatabase; if (result != null && result.Name.Contains(databaseName, StringComparison.OrdinalIgnoreCase)) { await this.client.Databases.DeleteAsync( this.config.Global.ResourceGroup, this.config.Global.DataExplorer.Name, databaseName); } } catch (CloudException e) { if (e.Body.Code == "ResourceNotFound") { throw new ResourceNotFoundException($"Unable to Delete kusto database {databaseName}"); } throw e; } }
private void VerifyReadWriteDatabase(ReadWriteDatabase database, string databaseName, TimeSpan?softDeletePeriod, TimeSpan?hotCachePeriod, string clusterName) { var databaseFullName = ResourcesNamesUtils.GetFullDatabaseName(clusterName, databaseName); Assert.NotNull(database); Assert.Equal(database.Name, databaseFullName); Assert.Equal(database.SoftDeletePeriod, softDeletePeriod); Assert.Equal(database.HotCachePeriod, hotCachePeriod); }
private void VerifyReadWriteDatabase(ReadWriteDatabase database, string databaseName, TimeSpan?softDeletePeriod, TimeSpan?hotCachePeriod, string workspaceName, string kustoPoolName) { var databaseFullName = GetFullKustoDatabaseName(workspaceName, kustoPoolName, databaseName); Assert.NotNull(database); Assert.Equal(database.Name, databaseFullName); Assert.Equal(database.SoftDeletePeriod, softDeletePeriod); Assert.Equal(database.HotCachePeriod, hotCachePeriod); }
private void Initialize() { clusterForEventGridTestResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupForTest}/providers/Microsoft.Kusto/Clusters/{clusterForEventGridTest}"; eventHubNamespaceResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.EventHub/namespaces/testclientsns22"; eventHubResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.EventHub/namespaces/testclientsns22/eventhubs/testclientseh"; storageAccountForEventGridResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.Storage/storageAccounts/testclients"; iotHubResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.Devices/IotHubs/test-clients-iot"; privateNetworkSubnetId = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.Network/virtualNetworks/test-clients-vnet/subnets/default"; rgName = TestUtilities.GenerateName("sdktestrg"); resourcesClient.ResourceGroups.CreateOrUpdate(rgName, new ResourceGroup { Location = location }); clusterName = TestUtilities.GenerateName("testcluster"); followerClusterName = TestUtilities.GenerateName("testfollower"); databaseName = TestUtilities.GenerateName("testdatabase"); attachedDatabaseConfigurationName = TestUtilities.GenerateName("testattacheddatabaseconfiguration"); eventHubConnectionName = TestUtilities.GenerateName("eventhubConnection"); eventGridConnectinoName = TestUtilities.GenerateName("eventGridConnection"); iotHubConnectionName = TestUtilities.GenerateName("iothubConnection"); privateEndpointConnectionName = TestUtilities.GenerateName("privateendpointname"); managedPrivateEndpointName = TestUtilities.GenerateName("managedprivateendpointname"); sku1 = new AzureSku(name: "Standard_D13_v2", "Standard", capacity: 2); sku2 = new AzureSku(name: "Standard_D14_v2", "Standard", capacity: 2); trustedExternalTenants = new List <TrustedExternalTenant>(1) { new TrustedExternalTenant(this.tenantId) }; hotCachePeriod1 = TimeSpan.FromDays(2); softDeletePeriod1 = TimeSpan.FromDays(4); hotCachePeriod2 = TimeSpan.FromDays(3); softDeletePeriod2 = TimeSpan.FromDays(6); cluster = new Cluster(sku: new AzureSku(name: "Standard_D13_v2", "Standard", 2), location: location, trustedExternalTenants: trustedExternalTenants, identity: new Identity(IdentityType.SystemAssigned)); followerCluster = new Cluster(sku: new AzureSku(name: "Standard_D13_v2", "Standard", 2), location: location, trustedExternalTenants: trustedExternalTenants); database = new ReadWriteDatabase(location: location, softDeletePeriod: softDeletePeriod1, hotCachePeriod: hotCachePeriod1); eventhubConnection = new EventHubDataConnection(eventHubResourceId, consumerGroupName, location: location); eventGridDataConnection = new EventGridDataConnection(storageAccountForEventGridResourceId, eventHubResourceId, consumerGroupName, tableName: tableName, dataFormat: dataFormat, location: location); iotHubDataConnection = new IotHubDataConnection(iotHubResourceId, consumerGroupName, sharedAccessPolicyNameForIotHub, location: location); script = new Script(scriptUrl: scriptUrl, scriptUrlSasToken: scriptUrlSasToken, forceUpdateTag: forceUpdateTag, continueOnErrors: continueOnErrors); databasePrincipal = GetDatabasePrincipalList(dBprincipalMail, "Admin"); databasePrincipals = new List <DatabasePrincipal> { databasePrincipal }; var leaderClusterResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Kusto/Clusters/{clusterName}"; attachedDatabaseConfiguration = new AttachedDatabaseConfiguration(location: this.location, databaseName: databaseName, clusterResourceId: leaderClusterResourceId, defaultPrincipalsModificationKind: defaultPrincipalsModificationKind); keyVaultProperties = new KeyVaultProperties(KeyNameForKeyVaultPropertiesTest, KeyVersionForKeyVaultPropertiesTest, KeyVaultUriForKeyVaultPropertiesTest); }
private void Initialize() { rgName = TestUtilities.GenerateName("sdktestrg"); resourcesClient.ResourceGroups.CreateOrUpdate(rgName, new ResourceGroup { Location = this.location }); clusterName = TestUtilities.GenerateName("testcluster"); followerClusterName = TestUtilities.GenerateName("testfollower"); databaseName = TestUtilities.GenerateName("testdatabase"); attachedDatabaseConfigurationName = TestUtilities.GenerateName("testattacheddatabaseconfiguration"); eventHubConnectionName = TestUtilities.GenerateName("eventhubConnection"); eventGridConnectinoName = TestUtilities.GenerateName("eventGridConnection"); iotHubConnectionName = TestUtilities.GenerateName("iothubConnection"); scriptName = "dor"; sku1 = new AzureSku(name: "Standard_D13_v2", "Standard", capacity: 2); sku2 = new AzureSku(name: "Standard_D14_v2", "Standard", capacity: 2); trustedExternalTenants = new List <TrustedExternalTenant>(1) { new TrustedExternalTenant(this.tenantId) }; hotCachePeriod1 = TimeSpan.FromDays(2); softDeletePeriod1 = TimeSpan.FromDays(4); hotCachePeriod2 = TimeSpan.FromDays(3); softDeletePeriod2 = TimeSpan.FromDays(6); dataFormat = "CSV"; defaultPrincipalsModificationKind = "Replace"; cluster = new Cluster(sku: new AzureSku(name: "Standard_D13_v2", "Standard", 2), location: this.location, trustedExternalTenants: trustedExternalTenants); followerCluster = new Cluster(sku: new AzureSku(name: "Standard_D13_v2", "Standard", 2), location: this.location, trustedExternalTenants: trustedExternalTenants); database = new ReadWriteDatabase(location: this.location, softDeletePeriod: softDeletePeriod1, hotCachePeriod: hotCachePeriod1); eventhubConnection = new EventHubDataConnection(eventHubResourceId, consumerGroupName, location: this.location); eventGridDataConnection = new EventGridDataConnection(storageAccountForEventGridResourceId, eventHubResourceId, consumerGroupName, tableName: tableName, dataFormat: dataFormat, location: location); iotHubDataConnection = new IotHubDataConnection(iotHubResourceId, consumerGroupName, sharedAccessPolicyNameForIotHub, location: location); script = new Script(scriptUrl, scriptUrlSasToken, forceUpdateTag: forceUpdateTag, continueOnErrors: continueOnErrors); databasePrincipal = GetDatabasePrincipalList(dBprincipalMail, "Admin"); databasePrincipals = new List <DatabasePrincipal> { databasePrincipal }; var leaderClusterResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Kusto/Clusters/{clusterName}"; attachedDatabaseConfiguration = new AttachedDatabaseConfiguration(location: this.location, databaseName: databaseName, clusterResourceId: leaderClusterResourceId, defaultPrincipalsModificationKind: defaultPrincipalsModificationKind); keyVaultProperties = new KeyVaultProperties(KeyNameForKeyVaultPropertiesTest, KeyVaultUriForKeyVaultPropertiesTest, KeyVersionForKeyVaultPropertiesTest); }