Exemplo n.º 1
0
        public AutomationAccount CreateAutomationAccount(string resourceGroupName, string automationAccountName, string location, string plan, IDictionary tags)
        {
            Requires.Argument("ResourceGroupName", resourceGroupName).NotNull();
            Requires.Argument("Location", location).NotNull();
            Requires.Argument("AutomationAccountName", automationAccountName).ValidAutomationAccountName();

            IDictionary <string, string> accountTags = null;

            if (tags != null)
            {
                accountTags = tags.Cast <DictionaryEntry>().ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value.ToString());
            }

            var accountCreateParameters = new AutomationAccountCreateOrUpdateParameters()
            {
                Location   = location,
                Name       = automationAccountName,
                Properties = new AutomationAccountCreateOrUpdateProperties()
                {
                    Sku = new Sku()
                    {
                        Name = String.IsNullOrWhiteSpace(plan) ? Constants.DefaultPlan : plan,
                    }
                },
                Tags = accountTags
            };

            var account =
                this.automationManagementClient.AutomationAccounts.CreateOrUpdate(resourceGroupName,
                                                                                  accountCreateParameters).AutomationAccount;


            return(new AutomationAccount(resourceGroupName, account));
        }
 /// <summary>
 /// Create or update automation account.
 /// <see href="http://aka.ms/azureautomationsdk/automationaccountoperations" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure Resource group.
 /// </param>
 /// <param name='automationAccountName'>
 /// The name of the automation account.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the create or update automation account.
 /// </param>
 public static AutomationAccount CreateOrUpdate(this IAutomationAccountOperations operations, string resourceGroupName, string automationAccountName, AutomationAccountCreateOrUpdateParameters parameters)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, automationAccountName, parameters).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Create or update automation account.
 /// <see href="http://aka.ms/azureautomationsdk/automationaccountoperations" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure Resource group.
 /// </param>
 /// <param name='automationAccountName'>
 /// The name of the automation account.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the create or update automation account.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <AutomationAccount> CreateOrUpdateAsync(this IAutomationAccountOperations operations, string resourceGroupName, string automationAccountName, AutomationAccountCreateOrUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, automationAccountName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create an automation account.  (see
 /// http://aka.ms/azureautomationsdk/automationaccountoperations for
 /// more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IAutomationAccountOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the create or update automation
 /// account.
 /// </param>
 /// <returns>
 /// The response model for the create or update account operation.
 /// </returns>
 public static Task <AutomationAccountCreateOrUpdateResponse> CreateOrUpdateAsync(this IAutomationAccountOperations operations, string resourceGroupName, AutomationAccountCreateOrUpdateParameters parameters)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, parameters, CancellationToken.None));
 }
 /// <summary>
 /// Create an automation account.  (see
 /// http://aka.ms/azureautomationsdk/automationaccountoperations for
 /// more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IAutomationAccountOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the create or update automation
 /// account.
 /// </param>
 /// <returns>
 /// The response model for the create or update account operation.
 /// </returns>
 public static AutomationAccountCreateOrUpdateResponse CreateOrUpdate(this IAutomationAccountOperations operations, string resourceGroupName, AutomationAccountCreateOrUpdateParameters parameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IAutomationAccountOperations)s).CreateOrUpdateAsync(resourceGroupName, parameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }