public string TryCreateDataLakeStoreAccount(string resourceGroupName, string location, string accountName)
        {
            bool exists = false;
            DataLakeStoreAccountGetResponse accountGetResponse = null;

            try
            {
                accountGetResponse = dataLakeStoreManagementClient.DataLakeStoreAccount.Get(resourceGroupName, accountName);
                exists             = true;
            }
            catch
            {
                // do nothing because it doesn't exist
            }


            if (!exists)
            {
                dataLakeStoreManagementClient.DataLakeStoreAccount.Create(resourceGroupName,
                                                                          new DataLakeStoreAccountCreateOrUpdateParameters
                {
                    DataLakeStoreAccount = new DataLakeStoreAccount {
                        Location = location, Name = accountName
                    }
                });

                accountGetResponse = dataLakeStoreManagementClient.DataLakeStoreAccount.Get(resourceGroupName,
                                                                                            accountName);

                // wait for provisioning state to be Succeeded
                // we will wait a maximum of 15 minutes for this to happen and then report failures
                int minutesWaited       = 0;
                int timeToWaitInMinutes = 15;
                while (accountGetResponse.DataLakeStoreAccount.Properties.ProvisioningState !=
                       DataLakeStoreAccountStatus.Succeeded &&
                       accountGetResponse.DataLakeStoreAccount.Properties.ProvisioningState !=
                       DataLakeStoreAccountStatus.Failed && minutesWaited <= timeToWaitInMinutes)
                {
                    TestUtilities.Wait(60000); // Wait for one minute and then go again.
                    minutesWaited++;
                    accountGetResponse = dataLakeStoreManagementClient.DataLakeStoreAccount.Get(resourceGroupName,
                                                                                                accountName);
                }
            }

            // Confirm that the account creation did succeed
            ThrowIfTrue(
                accountGetResponse.DataLakeStoreAccount.Properties.ProvisioningState !=
                DataLakeStoreAccountStatus.Succeeded,
                "Account failed to be provisioned into the success state. Actual State: " +
                accountGetResponse.DataLakeStoreAccount.Properties.ProvisioningState);

            return(accountGetResponse.DataLakeStoreAccount.Properties.Endpoint);
        }
예제 #2
0
        public string TryCreateDataLakeAccount(string resourceGroupName, string dataLakeAccountName, string location)
        {
            var dataLakeCreateParameters = new DataLakeStoreAccountCreateOrUpdateParameters
            {
                DataLakeStoreAccount = new DataLakeStoreAccount
                {
                    Location = location,
                    Name     = dataLakeAccountName,
                }
            };

            var createResponse = dataLakeManagementClient.DataLakeStoreAccount.Create(resourceGroupName, dataLakeCreateParameters);

            ThrowIfTrue(createResponse.Status == Microsoft.Azure.OperationStatus.Failed, "dataLakeManagementClient.DataLakeAccount.Create did not result in a fully provisioned account");

            DataLakeStoreAccountGetResponse getResponse = dataLakeManagementClient.DataLakeStoreAccount.Get(resourceGroupName, dataLakeAccountName);
            var dataLakeAccountSuffix = getResponse.DataLakeStoreAccount.Properties.Endpoint.Replace(dataLakeAccountName + ".", "");

            ThrowIfTrue(string.IsNullOrEmpty(dataLakeAccountSuffix), "dataLakeManagementClient.DataLakeAccount.Create did not properly populate the host property");
            return(dataLakeAccountSuffix);
        }