您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

是应选择云服务还是其他服务?Should I choose cloud services or something else?

Azure 云服务是适合选择吗?Is Azure Cloud Services the choice for you? Azure 提供了用于运行应用程序的不同托管模型。Azure provides different hosting models for running applications. 每种模型提供一组不同服务,而你选择哪种模型完全取决于要做什么。Each one provides a different set of services, so which one you choose depends on exactly what you're trying to do.

计算选项Compute Options 目标受众Audience
应用服务App Service 任何设备的可缩放 Web 应用、移动应用、API 应用和逻辑应用Scalable Web Apps, Mobile Apps, API Apps, and Logic Apps for any device
云服务Cloud Services 对操作系统具有更高控制度的高可用、可缩放 n 层云应用程序Highly available, scalable n-tier cloud apps with more control of the OS
虚拟机Virtual Machines 可完全控制操作系统的自定义 Windows 和 Linux VMCustomized Windows and Linux VMs with complete control of the OS

告诉我有关云服务的信息Tell me about cloud services

云服务是平台即服务 (PaaS) 的一个例子。Cloud Services is an example of Platform-as-a-Service (PaaS). 应用服务 一样,这种技术旨在支持可缩放、可靠且经济节省的应用程序。Like App Service, this technology is designed to support applications that are scalable, reliable, and cheap to operate. 正如应用服务,云服务也托管在 VM 中,不过,在 VM 上对云服务的控制力度更大。Just like an App Service is hosted on VMs, so too are Cloud Services, however, you have more control over the VMs. 可以在云服务 VM 上安装自己的软件,还可以远程接入这些 VM。You can install your own software on Cloud Service VMs and you can remote into them.

cs_diagram

更多控制也意味着更不易于使用。More control also means less ease of use. 除非需要更多控制选项,否则,与云服务相比,在应用服务的 Web 应用中启动和运行 Web 应用程序通常要快速方便一些。Unless you need the additional control options, it's typically quicker and easier to get a web application up and running in Web Apps in App Service compared to Cloud Services.

有两种类型的云服务角色。There are two types of Cloud Service roles. 两者之间的唯一区别是角色在虚拟机上的托管方式。The only difference between the two is how your role is hosted on the virtual machine.

  • Web 角色Web role
    通过 IIS 自动部署和托管应用。Automatically deploys and hosts your app through IIS.

  • 辅助角色Worker role
    不要使用 IIS 独立运行应用。Does not use IIS and runs your app standalone.

例如,简单的应用程序可能只使用一个 web 角色为网站提供服务。For example, a simple application might use just a single web role, serving a website. 更复杂的应用程序可能使用一个 Web 角色来处理用户的传入请求,然后将这些请求传递给辅助角色进行处理。A more complex application might use a web role to handle incoming requests from users, then pass those requests on to a worker role for processing. (此通信可能使用服务总线Azure 队列。)(This communication could use Service Bus or Azure Queues.)

如上图所示,一个应用程序中的所有 VM 都在同一云服务中运行。As the preceding figure suggests, all the VMs in a single application run in the same cloud service. 用户通过单个公共 IP 地址访问应用程序,而请求会自动在应用程序的 VM 中进行负载均衡。Users access the application through a single public IP address, with requests automatically load balanced across the application's VMs. 该平台采用一种能够避免单点硬件故障的方式在云服务应用程序中缩放和部署 VM。The platform scales and deploys the VMs in a Cloud Services application in a way that avoids a single point of hardware failure.

即使应用程序在虚拟机中运行,理解云服务提供的是 PaaS 而非 IaaS 也很重要。Even though applications run in virtual machines, it's important to understand that Cloud Services provides PaaS, not IaaS. 以下办法有助于理解这一点:使用 IaaS(如 Azure 虚拟机),首先要创建和配置应用程序将运行的环境,然后将应用程序部署到此环境中。Here's one way to think about it: With IaaS, such as Azure Virtual Machines, you first create and configure the environment your application runs in, then deploy your application into this environment. 要负责该环境的大部分管理工作,如在每个 VM 中部署操作系统的新修补版本。You're responsible for managing much of this world, doing things such as deploying new patched versions of the operating system in each VM. 相反,在 PaaS 中,这样的环境似乎早已存在。In PaaS, by contrast, it's as if the environment already exists. 只需部署应用程序。All you have to do is deploy your application. 已处理它所运行的平台的管理工作,包括部署操作系统的新版本。Management of the platform it runs on, including deploying new versions of the operating system, is handled for you.

缩放和管理Scaling and management

使用云服务,无需创建虚拟机。With Cloud Services, you don't create virtual machines. 相反,提供一个配置文件,告知 Azure 每个 VM 需要多少个角色实例(如三个 Web 角色实例两个辅助角色实例),平台将创建它们。Instead, you provide a configuration file that tells Azure how many of each you'd like, such as three web role instances and two worker role instances, and the platform creates them for you. 虽然仍然要选择这些备份 VM 的大小,但不用直接自行进行创建。You still choose what size those backing VMs should be, but you don't explicitly create them yourself. 如果应用程序需要处理更大的负载,则可以要求增加 VM,Azure 将创建这些实例。If your application needs to handle a greater load, you can ask for more VMs, and Azure creates those instances. 如果负载降低,则可以关闭这些实例并停止为它们付费。If the load decreases, you can shut down those instances and stop paying for them.

通常通过两个步骤就能使云服务应用程序可供用户使用。A Cloud Services application is typically made available to users via a two-step process. 首先,开发人员将应用程序上传到该平台的暂存区域。A developer first uploads the application to the platform's staging area. 当开发人员准备好使应用程序上线后,他们会使用 Azure 门户从过渡环境切换到生产环境。When the developer is ready to make the application live, they use the Azure portal to swap staging with production. 暂存与生产之间的这种切换无需停机就可完成,这使运行的应用程序可在不打扰其用户的情况下升级到新版本。This switch between staging and production can be done with no downtime, which lets a running application be upgraded to a new version without disturbing its users.

监视Monitoring

云服务还提供监视功能。Cloud Services also provides monitoring. 像 Azure 虚拟机一样,它将检测到发生故障的物理服务器,并在新的计算机上重新启动原先在该服务器上运行的 VM。Like Azure Virtual Machines, it detects a failed physical server and restarts the VMs that were running on that server on a new machine. 云服务不仅检测硬件故障,还检测发生故障的 VM 和应用程序。But Cloud Services also detects failed VMs and applications, not just hardware failures. 与虚拟机不同,它在每个 Web 角色和辅助角色中都存在有代理,因此它能够在发生故障时启动新的 VM 和应用程序实例。Unlike Virtual Machines, it has an agent inside each web and worker role, and so it's able to start new VMs and application instances when failures occur.

云服务的 PaaS 特性还具有其他含义。The PaaS nature of Cloud Services has other implications, too. 其中一个最重要的含义是,应编写基于此技术构建的应用程序以在任何 Web 角色或辅助角色实例出现故障时正确运行。One of the most important is that applications built on this technology should be written to run correctly when any web or worker role instance fails. 要实现这一目标,云服务应用程序不应该在它自己的 VM 的文件系统中维持状态。To achieve this, a Cloud Services application shouldn't maintain state in the file system of its own VMs. 与使用 Azure 虚拟机创建的 VM 不同,对云服务 VM 所做的写入不是持久的;这与虚拟机数据磁盘完全不同。Unlike VMs created with Azure Virtual Machines, writes made to Cloud Services VMs aren't persistent; there's nothing like a Virtual Machines data disk. 相反,云服务应用程序应将所有状态明确写入 SQL 数据库、blob、表或其他某种外部存储中。Instead, a Cloud Services application should explicitly write all state to SQL Database, blobs, tables, or some other external storage. 以这种方式构建应用程序会使它们更易于扩展、抵抗故障的能力更强,这是云服务的两个重要目标。Building applications this way makes them easier to scale and more resistant to failure, both important goals of Cloud Services.

后续步骤Next steps

在 .NET 中创建云服务应用Create a cloud service app in .NET
在 Node.js 中创建云服务应用Create a cloud service app in Node.js
在 PHP 中创建云服务应用Create a cloud service app in PHP
在 Python 中创建云服务应用Create a cloud service app in Python