Azure 雲端服務概觀Overview of Azure Cloud Services

Azure 雲端服務是平台即服務 (PaaS) 的一個範例。Azure Cloud Services is an example of a platform as a service (PaaS). 這項技術如同 Azure App Service,是專為支援可調整、穩定可靠且操作成本低的應用程式而設計。Like Azure App Service, this technology is designed to support applications that are scalable, reliable, and inexpensive to operate. 如同 App Service 是裝載於虛擬機器 (VM) 上,Azure 雲端服務也是如此。In the same way that App Service is hosted on virtual machines (VMs), so too is Azure Cloud Services. 不過,您可更充分地掌控 VM。However, you have more control over the VMs. 您可以使用 Azure 雲端服務在 VM 上安裝您自己的軟體,並從遠端加以存取。You can install your own software on VMs that use Azure Cloud Services, and you can access them remotely.

Azure 雲端服務圖表

更充分的控制也意味著較低的易用性。More control also means less ease of use. 除非您需要額外控制選項,否則與 Azure 雲端服務相較之下,在 App Service 的 Web Apps 功能中通常可更快、更輕易地讓 Web 應用程式上線運作。Unless you need the additional control options, it's typically quicker and easier to get a web application up and running in the Web Apps feature of App Service compared to Azure Cloud Services.

Azure 雲端服務角色分為兩種。There are two types of Azure Cloud Services roles. 這兩者唯一的差別是您的角色在 VM 上裝載的方式:The only difference between the two is how your role is hosted on the VMs:

  • Web 角色:透過 IIS 自動部署和裝載您的應用程式。Web role: Automatically deploys and hosts your app through IIS.

  • 背景工作角色:不使用 IIS,獨立執行您的應用程式。Worker role: 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, and then pass those requests on to a worker role for processing. (此通訊可能會使用 Azure 服務匯流排Azure 佇列儲存體。)(This communication might use Azure Service Bus or Azure Queue storage.)

如上圖所示,單一應用程式中所有的 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. 該平台會在 Azure 雲端服務應用程式中調整和部署 VM,藉此避免發生單一硬體失敗點。The platform scales and deploys the VMs in an Azure Cloud Services application in a way that avoids a single point of hardware failure.

即使應用程式在虛擬機器中執行,也必須了解 Azure 雲端服務是提供 PaaS,而非 IaaS。Even though applications run in VMs, it's important to understand that Azure Cloud Services provides PaaS, not infrastructure as a service (IaaS). 以下有一個用來判別的方法。Here's one way to think about it. 若使用像是 Azure 虛擬機器等 IaaS,您會先建立及設定應用程式執行的環境。With IaaS, such as Azure Virtual Machines, you first create and configure the environment your application runs in. 然後,將應用程式部署至此環境。Then you deploy your application into this environment. 您負責管理大部分的環境,處理在各個 VM 中部署作業系統新修補版本等作業。You're responsible for managing much of this world, by 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

藉由 Azure 雲端服務,您不需要建立虛擬機器。With Azure Cloud Services, you don't create virtual machines. 您只需要提供組態檔,讓 Azure 知道您需要多少個執行個體,例如「3 個 Web 角色執行個體」和「2 個背景工作角色執行個體」。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." 接著,平台會為您建立這些項目。The platform then creates them for you. 您仍然可以選擇這些支援 VM 的 大小 ,但您不需自行建立這些 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.

Azure 雲端服務應用程式一般透過兩個步驟的程序提供給使用者使用。An Azure 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

Azure 雲端服務也提供監視。Azure Cloud Services also provides monitoring. 和虛擬機器一樣,它會偵測故障的實體伺服器,並且在新機器上重新啟動原先在該伺服器上執行的 VM。Like Virtual Machines, it detects a failed physical server and restarts the VMs that were running on that server on a new machine. 不過,Azure 雲端服務也會偵測故障的 VM 和應用程式,而不只是硬體故障。But Azure 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.

Azure 雲端服務的 PaaS 性質也有其他意涵。The PaaS nature of Azure 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. 為了實現這一點,Azure 雲端服務應用程式不應該在本身 VM 的檔案系統中保持狀態。To achieve this, an Azure Cloud Services application shouldn't maintain state in the file system of its own VMs. 不同於透過虛擬機器建立的 VM,對 Azure 雲端服務 VM 的寫入不會持續存在。Unlike VMs created with Virtual Machines, writes made to Azure Cloud Services VMs aren't persistent. 沒有類似虛擬機器資料磁碟的項目。There's nothing like a Virtual Machines data disk. Azure 雲端服務應用程式反而應該將所有狀態明確寫入 Azure SQL 資料庫、Blob、表格或其他一些外部儲存體。Instead, an Azure Cloud Services application should explicitly write all state to Azure SQL Database, blobs, tables, or some other external storage. 以這種方式建立應用程式使得調整更簡單,而且更能夠因應故障,這是 Azure 雲端服務的兩個重要目標。Building applications this way makes them easier to scale and more resistant to failure, which are both important goals of Azure Cloud Services.

後續步驟Next steps