/// <summary>
 /// Create a certificate.  (see
 /// http://aka.ms/azureautomationsdk/certificateoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.ICertificateOperations.
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters supplied to the create certificate
 /// operation.
 /// </param>
 /// <returns>
 /// The response model for the create certificate operation.
 /// </returns>
 public static CertificateCreateResponse Create(this ICertificateOperations operations, string automationAccount, CertificateCreateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((ICertificateOperations)s).CreateAsync(automationAccount, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        private Certificate CreateCertificateInternal(string automationAccountName, string name, string path,
            SecureString password, string description, bool exportable)
        {
            var cert = (password == null)
                ? new X509Certificate2(path, String.Empty, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet)
                : new X509Certificate2(path, password, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);

            var ccprop = new CertificateCreateProperties()
            {
                Description = description,
                Base64Value = Convert.ToBase64String(cert.Export(X509ContentType.Pkcs12)),
                Thumbprint = cert.Thumbprint,
                IsExportable = exportable
            };

            var ccparam = new CertificateCreateParameters() { Name = name, Properties = ccprop };

            var certificate = this.automationManagementClient.Certificates.Create(automationAccountName, ccparam).Certificate;

            return new Certificate(automationAccountName, certificate);
        }
 /// <summary>
 /// Create a certificate.  (see
 /// http://aka.ms/azureautomationsdk/certificateoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.ICertificateOperations.
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters supplied to the create certificate
 /// operation.
 /// </param>
 /// <returns>
 /// The response model for the create certificate operation.
 /// </returns>
 public static Task<CertificateCreateResponse> CreateAsync(this ICertificateOperations operations, string automationAccount, CertificateCreateParameters parameters)
 {
     return operations.CreateAsync(automationAccount, parameters, CancellationToken.None);
 }