/// <summary> /// Creates the specified Data Lake Store account. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.DataLake.Store.IDataLakeStoreAccountOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group the account will be /// associated with. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the create Data Lake Store account /// operation. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request and error information regarding /// the failure. /// </returns> public static AzureAsyncOperationResponse BeginCreate(this IDataLakeStoreAccountOperations operations, string resourceGroupName, DataLakeStoreAccountCreateOrUpdateParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IDataLakeStoreAccountOperations)s).BeginCreateAsync(resourceGroupName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public DataLakeStoreAccount CreateOrUpdateAccount(string resourceGroupName, string accountName, string defaultGroup, string location, Hashtable[] customTags = null) { if (string.IsNullOrEmpty(resourceGroupName)) { resourceGroupName = GetResourceGroupByAccount(accountName); } var tags = TagsConversionHelper.CreateTagDictionary(customTags, true); var parameters = new DataLakeStoreAccountCreateOrUpdateParameters { DataLakeStoreAccount = new DataLakeStoreAccount { Name = accountName, Location = location, Properties = new DataLakeStoreAccountProperties { DefaultGroup = defaultGroup }, Tags = tags ?? new Dictionary<string, string>() } }; var accountExists = false; try { if (GetAccount(resourceGroupName, accountName) != null) { accountExists = true; } } catch { // intentionally empty since if there is any exception attempting to // get the account we know it doesn't exist and we will attempt to create it fresh. } var response = accountExists ? _client.DataLakeStoreAccount.Update(resourceGroupName, parameters) : _client.DataLakeStoreAccount.Create(resourceGroupName, parameters); if (response.Status != OperationStatus.Succeeded) { throw new CloudException(string.Format(Properties.Resources.LongRunningOperationFailed, response.Error.Code, response.Error.Message)); } return _client.DataLakeStoreAccount.Get(resourceGroupName, accountName).DataLakeStoreAccount; }
public string TryCreateDataLakeAccount(string resourceGroupName, string dataLakeAccountName, string location) { var dataLakeCreateParameters = new DataLakeStoreAccountCreateOrUpdateParameters { DataLakeStoreAccount = new DataLakeStoreAccount { Location = location, Name = dataLakeAccountName, } }; var createResponse = dataLakeStoreManagementClient.DataLakeStoreAccount.Create(resourceGroupName, dataLakeCreateParameters); ThrowIfTrue(createResponse.Status != Microsoft.Azure.OperationStatus.Succeeded, "dataLakeManagementClient.Account.Create did not result in a fully provisioned account"); var dataLakeAccountSuffix = dataLakeStoreManagementClient.DataLakeStoreAccount.Get(resourceGroupName, dataLakeAccountName).DataLakeStoreAccount.Properties.Endpoint.Replace(dataLakeAccountName + ".", ""); ThrowIfTrue(string.IsNullOrEmpty(dataLakeAccountSuffix), "dataLakeManagementClient.Account.Create did not properly populate the host property"); return dataLakeAccountSuffix; }
/// <summary> /// Creates the specified Data Lake Store account. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.DataLake.Store.IDataLakeStoreAccountOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group the account will be /// associated with. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the create Data Lake Store account /// operation. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request and error information regarding /// the failure. /// </returns> public static Task<AzureAsyncOperationResponse> BeginCreateAsync(this IDataLakeStoreAccountOperations operations, string resourceGroupName, DataLakeStoreAccountCreateOrUpdateParameters parameters) { return operations.BeginCreateAsync(resourceGroupName, parameters, CancellationToken.None); }