/// <summary>
 /// Initializes a new instance of the
 /// DataLakeStoreAccountCreateOrUpdateParameters class with required
 /// arguments.
 /// </summary>
 public DataLakeStoreAccountCreateOrUpdateParameters(DataLakeStoreAccount dataLakeStoreAccount)
     : this()
 {
     if (dataLakeStoreAccount == null)
     {
         throw new ArgumentNullException("dataLakeStoreAccount");
     }
     this.DataLakeStoreAccount = dataLakeStoreAccount;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the
 /// DataLakeStoreAccountCreateOrUpdateParameters class with required
 /// arguments.
 /// </summary>
 public DataLakeStoreAccountCreateOrUpdateParameters(DataLakeStoreAccount dataLakeStoreAccount)
     : this()
 {
     if (dataLakeStoreAccount == null)
     {
         throw new ArgumentNullException("dataLakeStoreAccount");
     }
     this.DataLakeStoreAccount = dataLakeStoreAccount;
 }
        public string TryCreateDataLakeStoreAccount(string resourceGroupName, string location, string accountName)
        {
            bool exists = false;

            Microsoft.Azure.Management.DataLake.Store.Models.DataLakeStoreAccount accountGetResponse = null;
            try
            {
                accountGetResponse = dataLakeStoreManagementClient.Account.Get(resourceGroupName, accountName);
                exists             = true;
            }
            catch
            {
                // do nothing because it doesn't exist
            }


            if (!exists)
            {
                dataLakeStoreManagementClient.Account.Create(resourceGroupName, accountName,
                                                             new Microsoft.Azure.Management.DataLake.Store.Models.DataLakeStoreAccount {
                    Location = location, Name = accountName
                });

                accountGetResponse = dataLakeStoreManagementClient.Account.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.Properties.ProvisioningState !=
                       DataLakeStoreAccountStatus.Succeeded &&
                       accountGetResponse.Properties.ProvisioningState !=
                       DataLakeStoreAccountStatus.Failed && minutesWaited <= timeToWaitInMinutes)
                {
                    TestUtilities.Wait(60000); // Wait for one minute and then go again.
                    minutesWaited++;
                    accountGetResponse = dataLakeStoreManagementClient.Account.Get(resourceGroupName,
                                                                                   accountName);
                }
            }

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

            return(accountGetResponse.Properties.Endpoint.Replace(string.Format("{0}.", accountName), ""));
        }
        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 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.
            }

            return accountExists
                ? _client.Account.Update(resourceGroupName,accountName, parameters)
                : _client.Account.Create(resourceGroupName, accountName, parameters);
        }
        public DataLakeStoreAccount CreateOrUpdateAccount(
            string resourceGroupName,
            string accountName,
            string defaultGroup, 
            string location, 
            Hashtable customTags = null, 
            EncryptionIdentity identity = null, 
            EncryptionConfig config = null, 
            IList<TrustedIdProvider> trustedProviders = null,
            IList<FirewallRule> firewallRules = null)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccount(accountName);
            }

            var tags = TagsConversionHelper.CreateTagDictionary(customTags, true);

            var parameters = new DataLakeStoreAccount
            {
                Name = accountName,
                Location = location,
                Properties = new DataLakeStoreAccountProperties
                {
                    DefaultGroup = defaultGroup,
                },
                Tags = tags ?? new Dictionary<string, string>()
            };

            if (identity != null)
            {
                parameters.Properties.EncryptionState = EncryptionState.Enabled;
                parameters.Identity = identity;
                parameters.Properties.EncryptionConfig = config ?? new EncryptionConfig
                {
                    Type = EncryptionConfigType.ServiceManaged
                };
            }

            if (trustedProviders != null && trustedProviders.Count > 0)
            {
                parameters.Properties.TrustedIdProviders = trustedProviders;
                parameters.Properties.TrustedIdProviderState = TrustedIdProviderState.Enabled;
            }

            if (firewallRules != null && firewallRules.Count > 0)
            {
                parameters.Properties.FirewallRules = firewallRules;
                parameters.Properties.FirewallState = FirewallState.Enabled;
            }

            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.
            }

            return accountExists
                ? _client.Account.Update(resourceGroupName, accountName, parameters)
                : _client.Account.Create(resourceGroupName, accountName, parameters);
        }