PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

Markdown | 128 lines | 97 code | 31 blank | 0 comment | 0 complexity | 68a83310ac1e6a4499d1ccf4d974bc4e MD5 | raw file
  1. <properties
  2. pageTitle="Setting up a Service Fabric cluster using Visual Studio | Microsoft Azure"
  3. description="Describes how to set up a Service Fabric cluster by using Azure Resource Manager (ARM) template created by an Azure Resource Group project in Visual Studio"
  4. services="service-fabric"
  5. documentationCenter=".net"
  6. authors="karolz-ms"
  7. manager="adegeo"
  8. editor=""/>
  9. <tags
  10. ms.service="service-fabric"
  11. ms.devlang="dotNet"
  12. ms.topic="article"
  13. ms.tgt_pltfrm="NA"
  14. ms.workload="NA"
  17. # Set up a Service Fabric cluster by using Visual Studio
  18. This article describes how to set up an Azure Service Fabric cluster by using Visual Studio and an Azure Resource Manager (ARM) template. We will use a Visual Studio Azure resource group project to create the template. After the template has been created, it can be deployed directly to Azure from Visual Studio, but it can also be used from a script or as part of continuous integration (CI) facility.
  19. ## Create a Service Fabric cluster template by using an Azure resource group project
  20. To get started, open Visual Studio and create an Azure resource group project (it is available in the **Cloud** folder):
  21. ![New Project dialog with Azure Resource Group project selected][1]
  22. You can create a new Visual Studio solution for this project or add it to an existing solution.
  23. >[AZURE.NOTE] If you do not see the Azure resource group project under the Cloud node, you do not have the Azure SDK installed. Launch Web Platform Installer ([install it now]( if you have not already), and then search for "Azure SDK for .NET" and install the version that is compatible with your version of Visual Studio.
  24. After you hit the OK button, Visual Studio will ask you to select the Resource Manager template you want to create:
  25. ![Select Azure Template dialog with Service Fabric Cluster template selected][2]
  26. Select the Service Fabric Cluster template and hit the OK button again. The project and the Resource Manager template have now been created.
  27. ## Prepare the template for deployment
  28. Before the template is deployed to create the cluster, you must provide values for the required template parameters. These parameter values are read from the `ServiceFabricCluster.parameters.json` file, which is in the `Templates` folder of the resource group project. Open the file and provide the following values:
  29. |Parameter name |Description|
  30. |----------------------- |--------------------------|
  31. |adminUserName |The name of the administrator account for Service Fabric machines (nodes).|
  32. |certificateThumbprint |The thumbprint of the certificate that will secure the cluster.|
  33. |sourceVaultResourceId |The *resource ID* of the key vault where the certificate that secures the cluster is stored.|
  34. |certificateUrlValue |The URL of the cluster security certificate.|
  35. The Visual Studio Service Fabric Resource Manager template creates a secure cluster that is protected by a certificate. This certificate is identified by the last three template parameters (`certificateThumbprint`, `sourceVaultValue`, and `certificateUrlValue`), and it must exist in an **Azure Key Vault**. For more information on how to create the cluster security certificate, see [Service Fabric cluster security scenarios]( article.
  36. ## Optional: change the cluster name
  37. Every Service Fabric cluster has a name. When a Fabric cluster is created in Azure, cluster name determines (together with the Azure region) the Domain Name System (DNS) name for the cluster. For example, if you name your cluster `myBigCluster`, and the location (Azure region) of the resource group that will host the new cluster is East US, the DNS name of the cluster will be ``.
  38. By default the cluster name is generated automatically and made unique by attaching a random suffix to a "cluster" prefix. This makes it very easy to use the template as part of a **continuous integration** (CI) system. If you want to use a specific name for your cluster, one that is meaningful to you, set the value of the `clusterName` variable in the Resource Manager template file (`ServiceFabricCluster.json`) to your chosen name. It is the first variable defined in that file.
  39. ## Optional: add public application ports
  40. You may also want to change the public application ports for the cluster before you deploy it. By default, the template opens up just two public TCP ports (80 and 8081). If you need more for your applications, modify the Azure Load Balancer definition in the template. The definition is stored in the main template file (`ServiceFabricCluster.json`). Open that file and search for `loadBalancedAppPort`. You will notice that each port is associated with three artifacts:
  41. 1. A template variable that defines the TCP port value for the port:
  42. ```json
  43. "loadBalancedAppPort1": "80"
  44. ```
  45. 2. A *probe* that defines how frequently and for how long the Azure load balancer will attempt to use a specific Service Fabric node before failing over to another one. The probes are part of the Load Balancer resource. Here is the probe definition for the first default application port:
  46. ```json
  47. {
  48. "name": "AppPortProbe1",
  49. "properties": {
  50. "intervalInSeconds": 5,
  51. "numberOfProbes": 2,
  52. "port": "[variables('loadBalancedAppPort1')]",
  53. "protocol": "Tcp"
  54. }
  55. }
  56. ```
  57. 3. A *load-balancing rule* that ties together the port and the probe, which enables load balancing across a set of Service Fabric cluster nodes:
  58. ```json
  59. {
  60. "name": "AppPortLBRule1",
  61. "properties": {
  62. "backendAddressPool": {
  63. "id": "[variables('lbPoolID0')]"
  64. },
  65. "backendPort": "[variables('loadBalancedAppPort1')]",
  66. "enableFloatingIP": false,
  67. "frontendIPConfiguration": {
  68. "id": "[variables('lbIPConfig0')]"
  69. },
  70. "frontendPort": "[variables('loadBalancedAppPort1')]",
  71. "idleTimeoutInMinutes": 5,
  72. "probe": {
  73. "id": "[concat(variables('lbID0'),'/probes/AppPortProbe1')]"
  74. },
  75. "protocol": "Tcp"
  76. }
  77. }
  78. ```
  79. If the applications that you plan to deploy to the cluster need more ports, you can add them by creating additional probe and load-balancing rule definitions. For more information on how to work with Azure Load Balancer through Resource Manager templates, see [Get started creating an internal load balancer using a template](../load-balancer/
  80. ## Deploy the template by using Visual Studio
  81. After you have saved all the required parameter values in the`` file, you are ready to deploy the template and create your Service Fabric cluster. Right-click the resource group project in Visual Studio Solution Explorer and choose **Deploy | New Deployment...**. Visual Studio will show the **Deploy to Resource Group** dialog box, asking you to authenticate to Azure, if necessary:
  82. ![Deploy to Resource Group dialog][3]
  83. The dialog box lets you choose an existing Resource Manager resource group for the cluster and gives you the option to create a new one. It normally makes sense to use a separate resource group for a Service Fabric cluster.
  84. After you hit the Deploy button, Visual Studio will prompt you to confirm the template parameter values. Hit the **Save** button. One parameter does not have a persisted value: the administrative account password for the cluster. You will need to provide a password value when Visual Studio prompts you for one.
  85. >[AZURE.NOTE] If PowerShell was never used to administer Azure from the machine that you are using now, you will need to do a little housekeeping.
  86. >1. Enable PowerShell scripting by running the [`Set-ExecutionPolicy`]( command. For development machines, "unrestricted" policy is usually acceptable.
  87. >2. Decide whether to allow diagnostic data collection from Azure PowerShell commands, and run [`Enable-AzureRmDataCollection`]( or [`Disable-AzureRmDataCollection`]( as necessary. This will avoid unnecessary prompts during template deployment.
  88. You can monitor the progress of the deployment process in the Visual Studio output window. Once the template deployment is completed, your new cluster is ready to use!
  89. If there are any errors, go to the [Azure portal]( and open the resource group that you deployed to. Click **All settings**, then click **Deployments** on the settings blade. A failed resource-group deployment will leave detailed diagnostic information there.
  90. >[AZURE.NOTE] Service Fabric clusters require a certain number of nodes to be up at all times in order to maintain availability and preserve state - referred to as "maintaining quorum". Consequently, it is typically not safe to shut down all of the machines in the cluster unless you have first performed a [full backup of your state](
  91. ## Next steps
  92. - [Learn about setting up Service Fabric cluster using the Azure portal](
  93. - [Learn how to manage and deploy Service Fabric applications using Visual Studio](
  94. <!--Image references-->
  95. [1]: ./media/service-fabric-cluster-creation-via-visual-studio/azure-resource-group-project-creation.png
  96. [2]: ./media/service-fabric-cluster-creation-via-visual-studio/selecting-azure-template.png
  97. [3]: ./media/service-fabric-cluster-creation-via-visual-studio/deploy-to-azure.png