public Credential CreateCredential(string automationAccountName, string name, string userName, string password, string description) { var credentialCreateParams = new AutomationManagement.Models.CredentialCreateParameters(); credentialCreateParams.Name = name; credentialCreateParams.Properties = new AutomationManagement.Models.CredentialCreateProperties(); if (description != null) { credentialCreateParams.Properties.Description = description; } if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) { new AzureAutomationOperationException(string.Format(Resources.ParameterEmpty, "Username or Password")); } credentialCreateParams.Properties.UserName = userName; credentialCreateParams.Properties.Password = password; var createdCredential = this.automationManagementClient.PsCredentials.Create(automationAccountName, credentialCreateParams); if (createdCredential == null || createdCredential.StatusCode != HttpStatusCode.Created) { new AzureAutomationOperationException(string.Format(Resources.AutomationOperationFailed, "Create", "credential", name, automationAccountName)); } return(new Credential(automationAccountName, createdCredential.Credential)); }
public CredentialInfo CreateCredential(string automationAccountName, string name, string userName, string password, string description) { var credentialCreateParams = new AutomationManagement.Models.CredentialCreateParameters(); credentialCreateParams.Name = name; credentialCreateParams.Properties = new AutomationManagement.Models.CredentialCreateProperties(); if (description != null) credentialCreateParams.Properties.Description = description; Requires.Argument("userName", userName).NotNull(); Requires.Argument("password", password).NotNull(); credentialCreateParams.Properties.UserName = userName; credentialCreateParams.Properties.Password = password; var createdCredential = this.automationManagementClient.PsCredentials.Create(automationAccountName, credentialCreateParams); if (createdCredential == null || createdCredential.StatusCode != HttpStatusCode.Created) { new AzureAutomationOperationException(string.Format(Resources.AutomationOperationFailed, "Create", "credential", name, automationAccountName)); } return new CredentialInfo(automationAccountName, createdCredential.Credential); }