/// <summary> /// Create Database If not exist /// Note: Created Database will have ulimited days of retention period and 0 cache period. /// </summary> /// <param name="databaseName">Azure Data Explorer Database Name.</param> public async Task CreateDatabaseIfNotExistAsync(string databaseName) { CheckNameRequest checkNameRequest = new CheckNameRequest(databaseName, Type.MicrosoftKustoClustersDatabases); CheckNameResult databaseNameAvailability = this.client.Databases.CheckNameAvailability( this.config.Global.ResourceGroup, this.config.Global.DataExplorer.Name, checkNameRequest); if (databaseNameAvailability.NameAvailable.GetValueOrDefault()) { try { await this.CreateDBInClusterAsync(databaseName, null, new TimeSpan(0, 0, 0, 0)); } catch (CloudException e) { if (e.Body.Code == "ResourceNotFound") { throw new ResourceNotFoundException($"Error Creating kusto database {databaseName}"); } throw e; } } }
/// <summary> /// Checks that the database name is valid and is not already in use. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group containing the Kusto cluster. /// </param> /// <param name='clusterName'> /// The name of the Kusto cluster. /// </param> /// <param name='resourceName'> /// The name of the resource. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <CheckNameResult> CheckNameAvailabilityAsync(this IDatabasesOperations operations, string resourceGroupName, string clusterName, CheckNameRequest resourceName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(resourceGroupName, clusterName, resourceName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Verify the specified Power BI Workspace Collection name is valid and not /// already in use. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='location'> /// Azure location /// </param> /// <param name='body'> /// Check name availability request /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <CheckNameResponse> CheckNameAvailabilityAsync(this IWorkspaceCollectionsOperations operations, string location, CheckNameRequest body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(location, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Checks that the database name is valid and is not already in use. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group containing the Kusto cluster. /// </param> /// <param name='clusterName'> /// The name of the Kusto cluster. /// </param> /// <param name='resourceName'> /// The name of the resource. /// </param> public static CheckNameResult CheckNameAvailability(this IDatabasesOperations operations, string resourceGroupName, string clusterName, CheckNameRequest resourceName) { return(operations.CheckNameAvailabilityAsync(resourceGroupName, clusterName, resourceName).GetAwaiter().GetResult()); }
/// <summary> /// Verify the specified Power BI Workspace Collection name is valid and not /// already in use. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='location'> /// Azure location /// </param> /// <param name='body'> /// Check name availability request /// </param> public static CheckNameResponse CheckNameAvailability(this IWorkspaceCollectionsOperations operations, string location, CheckNameRequest body) { return(Task.Factory.StartNew(s => ((IWorkspaceCollectionsOperations)s).CheckNameAvailabilityAsync(location, body), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }