EN
Bu içerik dilinizde bulunmamaktadır ancak İngilizce sürümüne buradan bakabilirsiniz.
1 / 2 bunu faydalı olarak değerlendirdi - Bu konuyu değerlendir

Add Service Certificate

Updated: January 9, 2012

The Add Service Certificate operation adds a certificate to a hosted service.

The Add Service Certificate operation is an asynchronous operation. To determine whether the management service has finished processing the request, call Get Operation Status. For more information on asynchronous operations, see Tracking Asynchronous Service Management Requests.

Request

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

 

Method Request URI HTTP Version

POST

https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/certificates

HTTP/1.1

URI Parameters

None.

Request Headers

The following table describes required and optional request headers.

 

Request Header Description

Content-Type

Required. Set this header to application/xml.

x-ms-version

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

Request Body

The format of the request body is as follows:


<?xml version="1.0" encoding="utf-8"?>
<CertificateFile xmlns=”http://schemas.microsoft.com/windowsazure”>
  <Data>base64-encoded-file</Data>
  <CertificateFormat>file-format</CertificateFormat>
  <Password>pfx-file-password</Password>
</CertificateFile>

ImportantImportant
The order of the elements in the request body is significant. If an element is required, it must appear in the XML in the order shown above.

 

Element name Description

Data

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

noteNote
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.

CertificateFormat

The service certificate format. Windows Azure supports the pfx and cer file formats.

Password

The password for a .pfx certificate. A .cer certificate does not require a password.

Response

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

Because Add Service Certificate is an asynchronous operation, you must call Get Operation Status to determine whether the operation is complete, has failed, or is still in progress.

Status Code

Because Add Service Certificate is an asynchronous operation, it always returns status code 202 (Accepted). To determine the status code for the operation once it is complete, call Get Operation Status. The status code is embedded in the response for this operation; if successful, it will be status code 200 (OK).

For information about status codes, see Service Management Status and Error Codes.

Response Headers

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 Description

x-ms-request-id

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. See Tracking Asynchronous Service Management Requests for more information.

Response Body

None.

Authorization

Any management certificate associated with the subscription specified by <subscription-id> can be used to authenticate this operation. For additional details, see Authenticating Service Management Requests.

Remarks

Use the Add Service Certificate operation to add an X.509 certificate to a hosted service for secure access to your web role and worker role applications. The operation returns immediately with a request ID in the x-ms-request-id header of the response to a successful request, while the certificate association with the hosted service is performed asynchronously by Windows Azure. To find out when the asynchronous add service certificate operation has completed, you can poll the Get Operation Status operation with the request ID. This will return an XML body with an Operation element containing a Status element which will have a value of InProgress, Failed, or Succeeded, depending on the status of the asynchronous operation. If you poll until the status is Failed or Succeeded, the Operation element will contain a status code representing the final status of the operation in the StatusCode element, and failed operations will contain additional error information in the Error element. See Get Operation Status for more details.

Example

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("https://management.core.windows.net/{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.
    req.ClientCertificates.Add(managementCertificate);

    // Construct the request body.
    using (var writer = new StreamWriter(req.GetRequestStream()))
    {
        writer.Write(string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
                                   <CertificateFile xmlns=""http://schemas.microsoft.com/windowsazure"">
                                   <Data>{0}</Data>
                                   <CertificateFormat>pfx</CertificateFormat>
                                   <Password>{1}</Password>
                                   </CertificateFile>", 
                                   Convert.ToBase64String(File.ReadAllBytes(pfxPath)), 
                                   password));
    }

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

Bunu faydalı buldunuz mu?
(1500 karakter kaldı)
© 2013 Microsoft. Tüm hakları saklıdır.
facebook page visit twitter rss feed newsletter