Enable HTTPS communication in Azure Cloud Services (extended support)

Communication with Microsoft Azure Cloud Services (extended support) is done by using the Hypertext Transfer Protocol Secure (HTTPS) protocol. This article discusses how to enable HTTPS communication for Cloud Services (extended support).

Prerequisites

General steps for project deployment

The general steps to deploy a Cloud Services (extended support) project into Azure are as follows:

  1. Prepare your certificate.

  2. Configure your project.

  3. Package the project file into the service definition (.csdef), service configuration (.cscfg), and service package (.cspkg) files of your cloud service.

  4. Change the configuration of the Cloud Services (extended support) resource, if necessary. For example, you could make any of the following modifications:

    1. Update the package URL.
    2. Configure the URL setting.
    3. Update the operating system secrets setting.
  5. Deploy and update the new project into Azure.

Note

The project can be deployed through several different methods, such as by using the following tools:

Regardless of the deployment method, the general deployment steps are the same.

The first two of these steps are necessary for all deployment methods. These steps are discussed in the Code changes section. The remaining steps are also important, but they don't always require manual user intervention. For example, the steps might be done automatically by a tool such as Visual Studio. The last three of these steps are discussed in the Configuration changes section.

Code changes

To make the code changes to prepare your certificate and configure your project, take the following steps:

  1. Follow the instructions to upload a certificate to the key vault through step 6.

  2. Write down the thumbprint of the certificate (a 40-digit hexadecimal string).

  3. In the service configuration (.cscfg) file of your project, add the certificate thumbprint to the role in which you want to use the certificate. For example, if you want to use the certificate as the SSL certificate to communicate with a WebRole, you might add XML code that resembles the following snippet for WebRole1 as the first child of the root ServiceConfiguration element:

    <Role name="WebRole1">
      <Instances count="1" />
      <Certificates>
        <Certificate
          name="Certificate1"
          thumbprint="0123456789ABCDEF0123456789ABCDEF01234567"
          thumbprintAlgorithm="sha1"
        />
      </Certificates>
    </Role>
    

    You can customize the name of the certificate, but it must match the certificate name that's used in the service definition (.csdef) file.

  4. In the service definition (.csdef) file, add the following elements.

    Parent XPath Elements to add Attributes to use
    /ServiceDefinition/WebRole/Sites/Site/Bindings Binding name, endpointName
    /ServiceDefinition/WebRole/Endpoints InputEndpoint name, protocol, port, certificate
    /ServiceDefinition/WebRole Certificates/Certificate name, storeLocation, storeName, permissionLevel

    The Certificates element has to be added directly after the closing Endpoints tag. It doesn't contain any attributes. It contains only child Certificate elements.

    For example, your service definition file might resemble the following XML code:

    <?xml version="1.0" encoding="utf-8"?>
    <ServiceDefinition name="CSESOneWebRoleHTTPS" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
      <WebRole name="WebRole1" vmsize="Standard_D1_v2">
        <Sites>
          <Site name="Web">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" />
              <Binding name="HttpsIn" endpointName="HttpsIn" />
            </Bindings>
          </Site>
        </Sites>
        <Endpoints>
          <InputEndpoint name="Endpoint1" protocol="http" port="80" />
          <InputEndpoint name="HttpsIn" protocol="https" port="443" certificate="Certificate1" />
        </Endpoints>
        <Certificates>
          <Certificate name="Certificate1" storeLocation="LocalMachine" storeName="My" permissionLevel="limitedOrElevated" />
        </Certificates>
      </WebRole>
    </ServiceDefinition>
    

    In this example, the service definition file is modified to bind an input endpoint of HttpsIn for the HTTPS protocol on port 443. It uses the Certificate1 certificate for a store that has a name of My and a location of LocalMachine for just a limited or elevated permission level. The certificate names in the InputEndpoint and Certificate elements match each other. They also match the certificate name that was used in the service configuration (.cscfg) file from the previous step.

Configuration changes

Instructions for changing your cloud service configuration differ according to how your cloud service was deployed. These instructions are shown on the following tabs. Each tab represents a different method of deployment.

Before you proceed, see Deploy a Azure Cloud Services (extended support) using the Azure portal. Then, follow these steps to make the correct configuration changes through the Azure portal:

  1. Go to the blog entry that's titled Manual migration from classic Cloud Service to Cloud Service Extended Support with ARM template, and follow steps 7 through 9. These instructions show you how to do the following steps:

    • Package the project.

    • Upload the generated service package (<project-name>.cspkg) and cloud service configuration (ServiceConfiguration.Cloud.cscfg) files into a storage account container for your cloud service.

      Note

      You'll also have to upload the service definition (ServiceDefinition.csdef) file by using the same process that's described for the other two files.

    • Generate a shared access signature (SAS) URL for each of the uploaded files.

  2. In the Azure portal, return to the Overview page of your cloud service, and then select Update.

  3. On the Update cloud service page, make the following changes on the Basics tab:

    1. In the Package/configuration/service definition location field, select From blob.

    2. In the Upload a package (.cspkg, .zip) field, follow these steps:

      1. Select the Browse link.
      2. Select the storage account and container to which you uploaded files.
      3. In the container page, select the corresponding file (in this case, <project-name>.cspkg), and then select the Select button.
    3. For the Upload a configuration (.cscfg) field (and ServiceConfiguration.Cloud.cscfg file), repeat the subprocedure that's outlined in the previous step.

    4. For the Upload a service definition (.csdef) field (and ServiceDefinition.csdef file), repeat the subprocedure again.

  4. Select the Configuration tab.

  5. In the Key vault field, select the key vault in which you uploaded the certificate (earlier in the Code changes section). After the certificate is found in the selected key vault, the listed certificate displays a Status of Found.

  6. To deploy the newly configured project, select the Update button.

After you make the configuration changes, customers will be able to communicate with your cloud services website by using the HTTPS protocol. If your certificate is self-signed, the browser might report a warning that the certificate isn't secure, but the browser won't block the connection.

Contact us for help

If you have questions or need help, create a support request, or ask Azure community support. You can also submit product feedback to Azure feedback community.