如何创建和部署 Azure 云服务(经典)How to create and deploy an Azure Cloud Service (classic)

Azure 门户提供了两种创建和部署云服务的方法:快速创建自定义创建The Azure portal provides two ways for you to create and deploy a cloud service: Quick Create and Custom Create.

本文介绍如何使用“快速创建”方法创建新的云服务,并使用“上传” 在 Azure 中上传和部署云服务包。This article explains how to use the Quick Create method to create a new cloud service and then use Upload to upload and deploy a cloud service package in Azure. 使用此方法时,Azure 门户会在进行操作时提供方便的链接供你完成所有要求。When you use this method, the Azure portal makes available convenient links for completing all requirements as you go. 如果创建云服务时还准备部署该云服务,则可以使用“自定义创建”同时执行这两项操作。If you're ready to deploy your cloud service when you create it, you can do both at the same time using Custom Create.


如果计划从 Azure DevOps 发布云服务,请使用“快速创建”,然后从“Azure 快速入门”或仪表板设置 Azure DevOps 发布。If you plan to publish your cloud service from Azure DevOps, use Quick Create, and then set up Azure DevOps publishing from the Azure Quickstart or the dashboard. 有关详细信息,请参阅使用 Azure DevOps 向 Azure 持续交付,或查看“快速入门”页的帮助 。For more information, see Continuous Delivery to Azure by Using Azure DevOps, or see help for the Quick Start page.


要将应用程序部署为 Azure 中的云服务,需要以下三个组件:Three components are required to deploy an application as a cloud service in Azure:

  • 服务定义Service Definition
    云服务定义文件 (.csdef) 可定义服务模型,包括角色数量。The cloud service definition file (.csdef) defines the service model, including the number of roles.
  • 服务配置Service Configuration
    云服务配置文件 (.cscfg) 提供云服务和各个角色的配置设置,包括角色实例的数量。The cloud service configuration file (.cscfg) provides configuration settings for the cloud service and individual roles, including the number of role instances.
  • 服务包Service Package
    服务包 (.cspkg) 包含应用程序代码和配置以及服务定义文件。The service package (.cspkg) contains the application code and configurations and the service definition file.

可以通过此处了解有关这些内容以及如何创建包的详细信息。You can learn more about these and how to create a package here.

准备应用Prepare your app

部署云服务之前,必须根据应用程序代码创建云服务包 (.cspkg),并创建云服务配置文件 (.cscfg)。Before you can deploy a cloud service, you must create the cloud service package (.cspkg) from your application code and a cloud service configuration file (.cscfg). Azure SDK 提供了用于准备这些必需的部署文件的工具。The Azure SDK provides tools for preparing these required deployment files. 可以从 Azure 下载 页安装 SDK,并使用希望用于开发应用程序代码的语言。You can install the SDK from the Azure Downloads page, in the language in which you prefer to develop your application code.

导出服务包之前,三种云服务功能需要特殊的配置:Three cloud service features require special configurations before you export a service package:

  • 若要部署使用传输层安全性 (TLS)(以前称为“安全套接字层”(SSL))进行数据加密的云服务,请为 TLS 配置应用程序If you want to deploy a cloud service that uses Transport Layer Security (TLS), previously known as Secure Sockets Layer (SSL), for data encryption, configure your application for TLS.
  • 如果要配置与角色实例的远程桌面连接,请为远程桌面配置角色If you want to configure Remote Desktop connections to role instances, configure the roles for Remote Desktop.
  • 如果要为云服务配置详细监视,请为云服务启用 Azure 诊断。If you want to configure verbose monitoring for your cloud service, enable Azure Diagnostics for the cloud service. 最少监视(默认监视级别)使用从角色实例(虚拟机)的主机操作系统中收集到的性能计数器 。Minimal monitoring (the default monitoring level) uses performance counters gathered from the host operating systems for role instances (virtual machines). 根据角色实例中的性能数据收集其他度量信息,以便对处理应用程序期间出现的问题进行进一步分析。Verbose monitoring gathers additional metrics based on performance data within the role instances to enable closer analysis of issues that occur during application processing. 若要了解如何启用 Azure 诊断,请参阅在 Azure 中启用诊断To find out how to enable Azure Diagnostics, see Enabling diagnostics in Azure.

要使用 Web 角色或辅助角色创建云服务,必须 创建服务包To create a cloud service with deployments of web roles or worker roles, you must create the service package.

准备阶段Before you begin

  • 如果尚未安装 Azure SDK,请单击“安装 Azure SDK”打开 Azure 下载页,然后下载要用于开发代码的相应语言的 SDK 。If you haven't installed the Azure SDK, click Install Azure SDK to open the Azure Downloads page, and then download the SDK for the language in which you prefer to develop your code. (也可以稍后执行此操作。)(You'll have an opportunity to do this later.)
  • 如果任何角色实例需要证书,请创建这些证书。If any role instances require a certificate, create the certificates. 云服务需要带有私钥的 .pfx 文件。Cloud services require a .pfx file with a private key. 可在创建和部署云服务时将这些证书上传到 Azure。You can upload the certificates to Azure as you create and deploy the cloud service.

创建和部署Create and deploy

  1. 登录到 Azure 门户Log in to the Azure portal.

  2. 单击“创建资源”>“计算” ,向下滚动到“云服务”并单击它 。Click Create a resource > Compute, and then scroll down to and click Cloud Service.

    发布云服务 1

  3. 在新的“云服务” 窗格中,输入“DNS 名称” 的值。In the new Cloud Service pane, enter a value for the DNS name.

  4. 创建一个新“资源组” 或选择一个现有的资源组。Create a new Resource Group or select an existing one.

  5. 选择“位置” 。Select a Location.

  6. 单击“包” 。Click Package. 这将打开“上载包” 窗格。This opens the Upload a package pane. 填写必填字段。Fill in the required fields. 如果任何角色包含单个实例,请确保选中“即使一个或多个角色包含单个实例也进行部署” 。If any of your roles contain a single instance, ensure Deploy even if one or more roles contain a single instance is selected.

  7. 请确保选中“开始部署” 。Make sure that Start deployment is selected.

  8. 单击“确定” ,这将关闭“上载包” 窗格。Click OK which will close the Upload a package pane.

  9. 如果不添加任何证书,请单击“创建” 。If you do not have any certificates to add, click Create.

    发布云服务 2

上传证书Upload a certificate

如果部署包已 配置为使用证书,现在就可以上传证书。If your deployment package was configured to use certificates, you can upload the certificate now.

  1. 选择“证书” ,并在“添加证书” 窗格中,选择 TLS/SSL 证书 .pfx 文件,并提供证书的密码 ,Select Certificates, and on the Add certificates pane, select the TLS/SSL certificate .pfx file, and then provide the Password for the certificate,

  2. 单击“附加证书” ,然后在“添加证书” 窗格上单击“确定” 。Click Attach certificate, and then click OK on the Add certificates pane.

  3. 在“云服务” 窗格上单击“创建” 。Click Create on the Cloud Service pane. 当部署达到“就绪” 状态时,可以继续执行后续步骤。When the deployment has reached the Ready status, you can proceed to the next steps.

    发布云服务 3

确认部署已成功完成Verify your deployment completed successfully

  1. 单击云服务实例。Click the cloud service instance.

    状态应显示该服务 正在运行The status should show that the service is Running.

  2. 在“概要” 下,单击“站点 URL” 在 Web 浏览器中打开云服务。Under Essentials, click the Site URL to open your cloud service in a web browser.


后续步骤Next steps