Add Service Certificate
Skjul indholdsfortegnelsen
Vis indholdsfortegnelsen
Dette indhold er ikke tilgængeligt på dit sprog, men her er den engelske version.

Add Service Certificate


Updated: July 10, 2015

The Add Service Certificate asynchronous operation adds a certificate to a cloud service.

The Add Service Certificate request may be specified as follows. Replace <subscription-id> with the subscription ID, and <service-name> with the DNS prefix name of the cloud service.


Request URI


You must make sure that the request that is made to the management service is secure. For additional details, see Authenticating Service Management Requests.

The following table describes the request headers.

Request Header



Required. Set this header to application/xml.


Required. Specifies the version of the operation to use for this request. This header should be set to 2009-10-01 or higher. For more information about versioning headers, see Service Management Versioning.

The format of the request body is as follows:

<?xml version="1.0" encoding="utf-8"?>
<CertificateFile xmlns=””>

The following table describes the elements in the request body.

Element name



Required. Specifies the base-64 encoded form of the .pfx or .cer file.


The service certificate is added as either a .pfx or .cer file. When retrieving the service certificate using the List Service Certificates or Get Service Certificate operation, only the public portion of the certificate is returned as a .cer file.


Required. Specifies the format of the service certificate.

Possible values are:

  • pfx

  • cer


Specifies the password for a .pfx certificate. A .cer certificate does not require a password.

The response includes an HTTP status code and a set of response headers.

A successful operation returns status code 200 (OK). For information about status codes, see Service Management Status and Error Codes.

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response Header



A value that uniquely identifies a request made against the management service. For an asynchronous operation, you can call Get Operation Status with the value of the header to determine whether the operation is complete, has failed, or is still in progress.

The following method constructs a request to add a service certificate, submits the request to the service, and returns the request ID.

public static string AddCertificate(string subscriptionId, string applicationName, X509Certificate2 managementCertificate, string pfxPath, string password)
    // Construct the request URI.    var req = (HttpWebRequest)WebRequest.Create(string.Format("{0}/services/hostedservices/{1}/certificates", subscriptionId, applicationName));

    // Set the request method and the content type for the request.
    req.Method = "POST";
    req.ContentType = "application/xml";

    // Add the x-ms-version header.
    req.Headers.Add("x-ms-version", "2009-10-01");

    // Add the certificate.

    // Construct the request body.
    using (var writer = new StreamWriter(req.GetRequestStream()))
        writer.Write(string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
                                   <CertificateFile xmlns="""">

    // Submit the request and return the request ID.
    return req.GetResponse().Headers["x-ms-request-id"];

© 2016 Microsoft