在 Windows 上準備您的開發環境Prepare your development environment on Windows

若要在您的 Windows 開發電腦上建立並執行Azure Service Fabric 應用程式, 請安裝 Service Fabric 執行時間、SDK 和工具。To build and run Azure Service Fabric applications on your Windows development machine, install the Service Fabric runtime, SDK, and tools. 您也必須執行 SDK 中包含的 Windows PowerShell 指令碼You also need to enable execution of the Windows PowerShell scripts included in the SDK.

必要條件Prerequisites

支援的作業系統版本Supported operating system versions

下列為支援開發的作業系統版本:The following operating system versions are supported for development:

  • Windows 7Windows 7
  • Windows 8/Windows 8.1Windows 8/Windows 8.1
  • Windows Server 2012 R2Windows Server 2012 R2
  • Windows Server 2016Windows Server 2016
  • Windows 10Windows 10

注意

Windows 7 支援:Windows 7 support:

  • 根據預設,Windows 7 只包含 Windows PowerShell 2.0。Windows 7 only includes Windows PowerShell 2.0 by default. Service Fabric PowerShell Cmdlet 需要 PowerShell 3.0 或更新版本。Service Fabric PowerShell cmdlets requires PowerShell 3.0 or higher. 您可以從 Microsoft 下載中心下載 Windows PowerShell 5.0You can download Windows PowerShell 5.0 from the Microsoft Download Center.
  • 無法在 Windows 7 上使用 Service Fabric 反向 Proxy。Service Fabric Reverse Proxy is not available on Windows 7.

安裝 SDK 和工具Install the SDK and tools

Web Platform Installer (WebPI) 是安裝 SDK 和工具的建議方式。Web Platform Installer (WebPI) is the recommended way to install the SDK and tools. 如果您在使用 WebPI 時接收到執行階段錯誤,您也可以在特定 Service Fabric 版本的版本資訊中找到安裝程式的直接連結。If you receive runtime errors using WebPI, you can also find direct links to the installers in the release notes for a specific Service Fabric release. 版本資訊可在 Service Fabric 小組部落格 (英文) 上的各個版本公告中找到。The release notes can be found in the various release announcements on the Service Fabric team blog.

注意

不支援本機 Service Fabric 開發叢集升級。Local Service Fabric development cluster upgrades are not supported.

使用 Visual Studio 2017 或2019To use Visual Studio 2017 or 2019

Service Fabric 工具是 Visual Studio 2017 和2019中的 Azure 開發工作負載的一部分。The Service Fabric Tools are part of the Azure Development workload in Visual Studio 2017 and 2019. 啟用此工作負載作為 Visual Studio 安裝的一部分。Enable this workload as part of your Visual Studio installation. 此外,您必須使用 Web Platform Installer 來安裝 Microsoft Azure Service Fabric SDK 和執行階段。In addition, you need to install the Microsoft Azure Service Fabric SDK and runtime using Web Platform Installer.

若要使用 Visual Studio 2015 (需要 Visual Studio 2015 Update 2 或更新版本)To use Visual Studio 2015 (requires Visual Studio 2015 Update 2 or later)

在 Visual Studio 2015 中,使用 Web Platform Installer,Service Fabric 工具會與 SDK 和執行階段一起安裝︰For Visual Studio 2015, the Service Fabric tools are installed together with the SDK and runtime using the Web Platform Installer:

僅限 SDK 安裝SDK installation only

如果您只需要 SDK,您可以安裝此套件︰If you only need the SDK, you can install this package:

目前的版本如下︰The current versions are:

  • Service Fabric SDK 和工具3.4.664Service Fabric SDK and Tools 3.4.664
  • Service Fabric 執行時間6.5.664Service Fabric runtime 6.5.664
  • Visual Studio 2015 2.5.20615.1 的 Service Fabric 工具Service Fabric Tools for Visual Studio 2015 2.5.20615.1
  • Visual Studio 2017 15.9 包含 Service Fabric Tools for Visual Studio 2.4.11024.1Visual Studio 2017 15.9 includes Service Fabric Tools for Visual Studio 2.4.11024.1
  • Visual Studio 2019 16.1 包含 Visual Studio 2.5.20423.3 的 Service Fabric 工具Visual Studio 2019 16.1 includes Service Fabric Tools for Visual Studio 2.5.20423.3

如需支援版本的清單,請參閱Service Fabric 版本For a list of supported versions, see Service Fabric versions

注意

單一機器叢集 (OneBox) 並不支援進行應用程式或叢集升級;如果您需要執行叢集升級,或是在執行應用程式升級時遇到任何問題,請刪除 OneBox 叢集並重新建立它。Single machine clusters (OneBox) are not supported for Application or Cluster upgrades; delete the OneBox cluster and recreate it if you need to perform a Cluster upgrade, or have any issues performing an Application upgrade.

啟用 PowerShell 指令碼執行Enable PowerShell script execution

Service Fabric 會使用 Windows PowerShell 指令碼,以便建立本機開發叢集,以及從 Visual Studio 部署應用程式。Service Fabric uses Windows PowerShell scripts for creating a local development cluster and for deploying applications from Visual Studio. 根據預設,Windows 會封鎖這些指令碼的執行。By default, Windows blocks these scripts from running. 若要啟用其,您必須修改 PowerShell 執行原則。To enable them, you must modify your PowerShell execution policy. 以系統管理員身分開啟 PowerShell 並輸入下列命令:Open PowerShell as an administrator and enter the following command:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser

安裝 Docker (選擇性)Install Docker (optional)

Service Fabric 是容器協調者,可用於將微服務部署至整個機器叢集。Service Fabric is a container orchestrator for deploying microservices across a cluster of machines. 若要在本機開發叢集上執行 Windows 容器應用程式,您必須先安裝 Docker for Windows。To run Windows container applications on your local development cluster, you must first install Docker for Windows. 取得 Docker CE for Windows (穩定)Get Docker CE for Windows (stable). 安裝並啟動 Docker 之後,以滑鼠右鍵按一下系統匣圖示,然後選取 [切換至 Windows 容器]。After installing and starting Docker, right-click on the tray icon and select Switch to Windows containers. 這是執行以 Windows 為基礎的 Docker 映像時的必要步驟。This step is required to run Docker images based on Windows.

後續步驟Next steps

現在您的開發環境已完成設定,您可以開始建置和執行應用程式。Now that you've finished setting up your development environment, start building and running apps.