/// <summary>
 /// Checks that account name is valid and is not in use.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='accountName'>
 /// The name of the storage account within the specified resource group.
 /// Storage account names must be between 3 and 24 characters in length and
 /// use numbers and lower-case letters only.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<CheckNameAvailabilityResult> CheckNameAvailabilityAsync(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }
 public virtual Response <CheckNameAvailabilityResult> CheckNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("StorageAccountsClient.CheckNameAvailability");
     scope.Start();
     try
     {
         return(RestClient.CheckNameAvailability(accountName, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
        public async Task <string> CreateValidAccountNameAsync(string prefix)
        {
            string accountName = prefix;

            for (int i = 0; i < 10; i++)
            {
                accountName = Recording.GenerateAssetName(prefix);
                StorageAccountCheckNameAvailabilityParameters parameter = new StorageAccountCheckNameAvailabilityParameters(accountName);
                CheckNameAvailabilityResult result = await DefaultSubscription.CheckStorageAccountNameAvailabilityAsync(parameter);

                if (result.NameAvailable == true)
                {
                    return(accountName);
                }
            }
            return(accountName);
        }
Beispiel #4
0
        internal HttpMessage CreateCheckAvailabilityRequest(StorageAccountCheckNameAvailabilityParameters accountName)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();

            uri.Reset(endpoint);
            uri.AppendPath("/subscriptions/", false);
            uri.AppendPath(subscriptionId, true);
            uri.AppendPath("/providers/Microsoft.Storage/checkNameAvailability", false);
            uri.AppendQuery("api-version", apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/json");
            var content = new Utf8JsonRequestContent();

            content.JsonWriter.WriteObjectValue(accountName);
            request.Content = content;
            message.SetProperty("UserAgentOverride", _userAgent);
            return(message);
        }
 public virtual async Task <Response <CheckNameAvailabilityResult> > CheckNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("StorageAccountsClient.CheckNameAvailability");
     scope.Start();
     try
     {
         return(await RestClient.CheckNameAvailabilityAsync(accountName, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 public static async Task <Response <CheckNameAvailabilityResult> > CheckStorageAccountNameAvailabilityAsync(this Subscription subscription, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
 {
     return(await GetExtensionClient(subscription).CheckStorageAccountNameAvailabilityAsync(accountName, cancellationToken).ConfigureAwait(false));
 }
 /// <summary>
 /// Checks that account name is valid and is not in use.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='accountName'>
 /// The name of the storage account within the specified resource group.
 /// Storage account names must be between 3 and 24 characters in length and use
 /// numbers and lower-case letters only.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <CheckNameAvailabilityResult> CheckNameAvailabilityAsync(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #8
0
        public static async Task <Response <CheckNameAvailabilityResult> > CheckStorageAccountNameAvailabilityAsync(this SubscriptionResource subscriptionResource, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(accountName, nameof(accountName));

            return(await GetExtensionClient(subscriptionResource).CheckStorageAccountNameAvailabilityAsync(accountName, cancellationToken).ConfigureAwait(false));
        }
Beispiel #9
0
 /// <summary>
 /// Checks that account name is valid and is not in use.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='accountName'>
 /// The name of the storage account within the specified resource group.
 /// Storage account names must be between 3 and 24 characters in length and use
 /// numbers and lower-case letters only.
 /// </param>
 public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName)
 {
     return(operations.CheckNameAvailabilityAsync(accountName).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Checks that account name is valid and is not in use.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='accountName'>
 /// The name of the storage account within the specified resource group.
 /// Storage account names must be between 3 and 24 characters in length and use
 /// numbers and lower-case letters only.
 /// </param>
 public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName)
 {
     return(Task.Factory.StartNew(s => ((IStorageAccountsOperations)s).CheckNameAvailabilityAsync(accountName), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 public static Response <CheckNameAvailabilityResult> CheckStorageAccountNameAvailability(this Subscription subscription, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
 {
     return(GetExtensionClient(subscription).CheckStorageAccountNameAvailability(accountName, cancellationToken));
 }
Beispiel #12
0
 public virtual Response <CheckNameAvailabilityResult> CheckStorageAccountNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
 {
     using var scope = StorageAccountClientDiagnostics.CreateScope("SubscriptionExtensionClient.CheckStorageAccountNameAvailability");
     scope.Start();
     try
     {
         var response = StorageAccountRestClient.CheckNameAvailability(Id.SubscriptionId, accountName, cancellationToken);
         return(response);
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
Beispiel #13
0
        public async Task <Response <CheckNameAvailabilityResult> > CheckAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
        {
            if (accountName == null)
            {
                throw new ArgumentNullException(nameof(accountName));
            }

            using var message = CreateCheckAvailabilityRequest(accountName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                CheckNameAvailabilityResult value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = CheckNameAvailabilityResult.DeserializeCheckNameAvailabilityResult(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Beispiel #14
0
        public static Response <CheckNameAvailabilityResult> CheckStorageAccountNameAvailability(this Subscription subscription, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
        {
            if (accountName == null)
            {
                throw new ArgumentNullException(nameof(accountName));
            }

            return(subscription.UseClientContext((baseUri, credential, options, pipeline) =>
            {
                var clientDiagnostics = new ClientDiagnostics(options);
                var restOperations = GetStorageAccountNameRestOperations(clientDiagnostics, credential, options, pipeline, subscription.Id.SubscriptionId, baseUri);
                using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.CheckStorageAccountNameAvailability");
                scope.Start();
                try
                {
                    var response = restOperations.CheckAvailability(accountName, cancellationToken);
                    return response;
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }
                                                 ));
        }
        public async virtual Task <Response <CheckNameAvailabilityResult> > CheckStorageAccountNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
        {
            if (accountName == null)
            {
                throw new ArgumentNullException(nameof(accountName));
            }

            using var scope = StorageAccountClientDiagnostics.CreateScope("SubscriptionExtensionClient.CheckStorageAccountNameAvailability");
            scope.Start();
            try
            {
                var response = await StorageAccountRestClient.CheckNameAvailabilityAsync(Id.SubscriptionId, accountName, cancellationToken).ConfigureAwait(false);

                return(response);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Beispiel #16
0
        public static Response <CheckNameAvailabilityResult> CheckStorageAccountNameAvailability(this SubscriptionResource subscriptionResource, StorageAccountCheckNameAvailabilityParameters accountName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(accountName, nameof(accountName));

            return(GetExtensionClient(subscriptionResource).CheckStorageAccountNameAvailability(accountName, cancellationToken));
        }
 /// <summary>
 /// Checks that account name is valid and is not in use.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='accountName'>
 /// The name of the storage account within the specified resource group.
 /// Storage account names must be between 3 and 24 characters in length and
 /// use numbers and lower-case letters only.
 /// </param>
 public static CheckNameAvailabilityResult CheckNameAvailability(this IStorageAccountsOperations operations, StorageAccountCheckNameAvailabilityParameters accountName)
 {
     return Task.Factory.StartNew(s => ((IStorageAccountsOperations)s).CheckNameAvailabilityAsync(accountName), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }