Example #1
0
 protected override void ProcessRecord()
 {
     if (!string.IsNullOrEmpty(Name))
     {
         // Get for single account
         WriteObject(DataLakeAnalyticsClient.GetAcount(ResourceGroupName, Name));
     }
     else
     {
         // List all accounts in given resource group if avaliable otherwise all accounts in the subscription
         var list = DataLakeAnalyticsClient.ListAccounts(ResourceGroupName, null, null, null);
         WriteObject(list, true);
     }
 }
Example #2
0
 protected override void ProcessRecord()
 {
     try
     {
         DataLakeAnalyticsClient.GetAcount(ResourceGroupName, Name);
         WriteObject(true);
     }
     catch (CloudException e)
     {
         if (e.Response.StatusCode == HttpStatusCode.NotFound)
         {
             WriteObject(false);
         }
         else
         {
             throw;
         }
     }
 }
Example #3
0
        protected override void ProcessRecord()
        {
            try
            {
                if (DataLakeAnalyticsClient.GetAcount(ResourceGroupName, Name) != null)
                {
                    throw new CloudException(string.Format(Resources.DataLakeAnalyticsAccountExists, Name));
                }
            }
            catch (CloudException ex)
            {
                if (ex.Error != null && !string.IsNullOrEmpty(ex.Error.Code) && ex.Error.Code == "ResourceNotFound" ||
                    ex.Message.Contains("ResourceNotFound"))
                {
                    // account does not exists so go ahead and create one
                }
                else if (ex.Error != null && !string.IsNullOrEmpty(ex.Error.Code) &&
                         ex.Error.Code == "ResourceGroupNotFound" || ex.Message.Contains("ResourceGroupNotFound"))
                {
                    // resource group not found, let create throw error don't throw from here
                }
                else
                {
                    // all other exceptions should be thrown
                    throw;
                }
            }

            var defaultStorage = new DataLakeStoreAccount
            {
                Name = DefaultDataLakeStore
            };

            WriteObject(DataLakeAnalyticsClient.CreateOrUpdateAccount(ResourceGroupName, Name, Location, defaultStorage,
                                                                      customTags: Tags));
        }