protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (this.Thumbprint != null)
            {
                if (this.ThumbprintAlgorithm == null)
                {
                    throw new ArgumentNullException("ThumbprintAlgorithm", Resources.MissingThumbprintAlgorithm);
                }

                var parameters = new ServiceCertificateGetParameters
                {
                    ServiceName =  ServiceName,
                    Thumbprint =  Thumbprint,
                    ThumbprintAlgorithm =  ThumbprintAlgorithm
                };
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.ServiceCertificates.Get(parameters),
                    (s, response) => new int[1].Select(i => ContextFactory<ServiceCertificateGetResponse, CertificateContext>(response, s)));
            }
            else
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.ServiceCertificates.List(this.ServiceName),
                    (s, response) => response.Certificates.Select(c =>
                                                                  {
                                                                      var context = ContextFactory<ServiceCertificateListResponse.Certificate, CertificateContext>(c, s);
                                                                      context.ServiceName = this.ServiceName;
                                                                      return context;
                                                                  }));
            }
        }
 /// <summary>
 /// The Get Service Certificate operation returns the public data for
 /// the specified X.509 certificate associated with a hosted service.
 /// (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460792.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IServiceCertificateOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Get Service Certificate
 /// operation.
 /// </param>
 /// <returns>
 /// The Get Service Certificate operation response.
 /// </returns>
 public static Task<ServiceCertificateGetResponse> GetAsync(this IServiceCertificateOperations operations, ServiceCertificateGetParameters parameters)
 {
     return operations.GetAsync(parameters, CancellationToken.None);
 }
 /// <summary>
 /// The Get Service Certificate operation returns the public data for
 /// the specified X.509 certificate associated with a hosted service.
 /// (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460792.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IServiceCertificateOperations.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Get Service Certificate operation.
 /// </param>
 /// <returns>
 /// The Get Service Certificate operation response.
 /// </returns>
 public static ServiceCertificateGetResponse Get(this IServiceCertificateOperations operations, ServiceCertificateGetParameters parameters)
 {
     try
     {
         return operations.GetAsync(parameters).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
 /// <summary>
 /// The Get Service Certificate operation returns the public data for
 /// the specified X.509 certificate associated with a hosted service.
 /// (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460792.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IServiceCertificateOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Get Service Certificate
 /// operation.
 /// </param>
 /// <returns>
 /// The Get Service Certificate operation response.
 /// </returns>
 public static ServiceCertificateGetResponse Get(this IServiceCertificateOperations operations, ServiceCertificateGetParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IServiceCertificateOperations)s).GetAsync(parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        protected PSArgument[] CreateServiceCertificateGetParameters()
        {
            ServiceCertificateGetParameters parameters = new ServiceCertificateGetParameters();

            return ConvertFromObjectsToArguments(new string[] { "Parameters" }, new object[] { parameters });
        }