/// <summary>
 /// Create the module identified by module name.  (see
 /// http://aka.ms/azureautomationsdk/moduleoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IModuleOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The create or update parameters for module.
 /// </param>
 /// <returns>
 /// The response model for the create or update module operation.
 /// </returns>
 public static ModuleCreateOrUpdateResponse CreateOrUpdate(this IModuleOperations operations, string resourceGroupName, string automationAccount, ModuleCreateOrUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IModuleOperations)s).CreateOrUpdateAsync(resourceGroupName, automationAccount, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Create the module identified by module name.  (see
 /// http://aka.ms/azureautomationsdk/moduleoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IModuleOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The create or update parameters for module.
 /// </param>
 /// <returns>
 /// The response model for the create or update module operation.
 /// </returns>
 public static Task<ModuleCreateOrUpdateResponse> CreateOrUpdateAsync(this IModuleOperations operations, string resourceGroupName, string automationAccount, ModuleCreateOrUpdateParameters parameters)
 {
     return operations.CreateOrUpdateAsync(resourceGroupName, automationAccount, parameters, CancellationToken.None);
 }
Ejemplo n.º 3
0
        public async Task<bool> SaveModuleAsync(ModuleModelProxy module)
        {
            var contentLink = new ContentLink();
            contentLink.Uri = new Uri(module.ModuleUrl);
            contentLink.Version = module.ModuleVersion;

            var moduleToSave = new ModuleCreateOrUpdateParameters();
            moduleToSave.Name = module.ModuleName;
            moduleToSave.Location = _connectionData.AzureRMLocation;

            moduleToSave.Properties = new ModuleCreateOrUpdateProperties();
            moduleToSave.Properties.ContentLink = contentLink;

            var response = await _client.Modules.CreateOrUpdateAsync(_connectionData.AzureRMGroupName, _connectionData.AzureAutomationAccount, moduleToSave);

            if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
            {
                _output.AppendLine("Unable to save the module at the moment, please verify your connectivity and try again.");
                return false;
            }

            return true;
        }