public Credential UpdateCredential(string automationAccountName, string name, string userName, string password, string description) { var credentialUpdateParams = new AutomationManagement.Models.CredentialUpdateParameters(); credentialUpdateParams.Name = name; credentialUpdateParams.Properties = new AutomationManagement.Models.CredentialUpdateProperties(); if (description != null) { credentialUpdateParams.Properties.Description = description; } if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) { new AzureAutomationOperationException(string.Format(Resources.ParameterEmpty, "Username or Password")); } credentialUpdateParams.Properties.UserName = userName; credentialUpdateParams.Properties.Password = password; var credential = this.automationManagementClient.PsCredentials.Update(automationAccountName, credentialUpdateParams); if (credential == null || credential.StatusCode != HttpStatusCode.OK) { new AzureAutomationOperationException(string.Format(Resources.AutomationOperationFailed, "Update", "credential", name, automationAccountName)); } var updatedCredential = this.GetCredential(automationAccountName, name); return(updatedCredential); }
public CredentialInfo UpdateCredential(string automationAccountName, string name, string userName, string password, string description) { var exisitngCredential = this.GetCredential(automationAccountName, name); var credentialUpdateParams = new AutomationManagement.Models.CredentialUpdateParameters(); credentialUpdateParams.Name = name; credentialUpdateParams.Properties = new AutomationManagement.Models.CredentialUpdateProperties(); credentialUpdateParams.Properties.Description = description ?? exisitngCredential.Description; credentialUpdateParams.Properties.UserName = userName; credentialUpdateParams.Properties.Password = password; var credential = this.automationManagementClient.PsCredentials.Update(automationAccountName, credentialUpdateParams); if (credential == null || credential.StatusCode != HttpStatusCode.OK) { new AzureAutomationOperationException(string.Format(Resources.AutomationOperationFailed, "Update", "credential", name, automationAccountName)); } var updatedCredential = this.GetCredential(automationAccountName, name); return updatedCredential; }