/// <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 patch parameters for module.
 /// </param>
 /// <returns>
 /// The response model for the get module operation.
 /// </returns>
 public static ModuleGetResponse Patch(this IModuleOperations operations, string resourceGroupName, string automationAccount, ModulePatchParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IModuleOperations)s).PatchAsync(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 patch parameters for module.
 /// </param>
 /// <returns>
 /// The response model for the get module operation.
 /// </returns>
 public static Task<ModuleGetResponse> PatchAsync(this IModuleOperations operations, string resourceGroupName, string automationAccount, ModulePatchParameters parameters)
 {
     return operations.PatchAsync(resourceGroupName, automationAccount, parameters, CancellationToken.None);
 }
예제 #3
0
        public Module UpdateModule(string resourceGroupName, string automationAccountName, string name,
            Uri contentLinkUri, string contentLinkVersion)
        {
            var moduleModel =
                this.automationManagementClient.Modules.Get(resourceGroupName, automationAccountName, name).Module;
            if (contentLinkUri != null)
            {
                var modulePatchParameters = new AutomationManagement.Models.ModulePatchParameters();

                modulePatchParameters.Name = name;
                modulePatchParameters.Properties = new ModulePatchProperties();
                modulePatchParameters.Properties.ContentLink = new AutomationManagement.Models.ContentLink();
                modulePatchParameters.Properties.ContentLink.Uri = contentLinkUri;
                modulePatchParameters.Properties.ContentLink.Version =
                    (String.IsNullOrWhiteSpace(contentLinkVersion))
                        ? Guid.NewGuid().ToString()
                        : contentLinkVersion;

                modulePatchParameters.Tags = moduleModel.Tags;

                this.automationManagementClient.Modules.Patch(resourceGroupName, automationAccountName,
                    modulePatchParameters);
            }
            var updatedModule =
                this.automationManagementClient.Modules.Get(resourceGroupName, automationAccountName, name).Module;
            return new Module(resourceGroupName, automationAccountName, updatedModule);
        }