Tutorial: Deploy a Service Fabric application to a cluster in Azure
This tutorial is part two of a series. It shows you how to deploy an Azure Service Fabric application to a new cluster in Azure.
In this tutorial, you learn how to:
- Create a party cluster.
- Deploy an application to a remote cluster by using Visual Studio.
In this tutorial series, you learn how to:
- Build a .NET Service Fabric application.
- Deploy the application to a remote cluster.
- Add an HTTPS endpoint to an ASP.NET Core front-end service.
- Configure CI/CD by using Visual Studio Team Services.
- Set up monitoring and diagnostics for the application.
Before you begin this tutorial:
- If you don't have an Azure subscription, create a free account.
- Install Visual Studio 2017, and install the Azure development and ASP.NET and web development workloads.
- Install the Service Fabric SDK.
Download the voting sample application
If you didn't build the voting sample application in part one of this tutorial series, you can download it. In a command window, run the following code to clone the sample app repository to your local machine.
git clone https://github.com/Azure-Samples/service-fabric-dotnet-quickstart
Publish to a Service Fabric cluster
Now that the application is ready, you can deploy it to a cluster directly from Visual Studio. A Service Fabric cluster is a network-connected set of virtual or physical machines into which your microservices are deployed and managed.
For this tutorial, you have two options for deployment of the voting application to a Service Fabric cluster by using Visual Studio:
- Publish to a trial (party) cluster.
- Publish to an existing cluster in your subscription. You can create Service Fabric clusters through the Azure portal by using PowerShell or Azure CLI scripts, or from an Azure Resource Manager template.
Many services use the reverse proxy to communicate with each other. Clusters created from Visual Studio and party clusters have reverse proxy enabled by default. If you're using an existing cluster, you must enable the reverse proxy in the cluster.
Find the voting web service endpoint for your Azure subscription
To publish the voting application to your own Azure subscription, find the endpoint of the front-end web service. If you use a party cluster, connect to port 8080 by using the automatically open voting sample. You don't need to configure it in the party cluster's load balancer.
The front-end web service is listening on a specific port. When the application deploys to a cluster in Azure, both the cluster and the application run behind an Azure load balancer. The application port must be opened by using a rule in the Azure load balancer for the cluster. The open port sends inbound traffic through to the web service. The port is found in the VotingWeb/PackageRoot/ServiceManifest.xml file in the Endpoint element. An example is port 8080.
<Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="8080" />
Join a party cluster
To publish the application to your own cluster within an Azure subscription, skip to the Publish the application by using Visual Studio section.
Party clusters are free, limited-time Service Fabric clusters hosted on Azure and run by the Service Fabric team. Anyone can deploy applications and learn about the platform. The cluster uses a single self-signed certificate for both node-to-node and client-to-node security.
Sign in and join a Windows cluster. To download the PFX certificate to your computer, select the PFX link. Select the How to connect to a secure Party cluster? link, and copy the certificate password. The certificate, certificate password, and Connection endpoint value are used in the following steps.
A limited number of party clusters are available per hour. If you get an error when you try to sign up for a party cluster, wait and try again. Or follow these steps in the Deploy a .NET app tutorial to create a Service Fabric cluster in your Azure subscription and deploy the application to it. If you don't already have an Azure subscription, you can create a free account.
On your Windows machine, install the PFX in the CurrentUser\My certificate store.
PS C:\mycertificates> Import-PfxCertificate -FilePath .\party-cluster-873689604-client-cert.pfx -CertStoreLocation Cert:\CurrentUser\My -Password (ConvertTo-SecureString 873689604 -AsPlainText -Force) PSParentPath: Microsoft.PowerShell.Security\Certificate::CurrentUser\My Thumbprint Subject ---------- ------- 3B138D84C077C292579BA35E4410634E164075CD CN=zwin7fh14scd.westus.cloudapp.azure.com
Remember the thumbprint for the next step.
By default, the web front-end service is configured to listen on port 8080 for incoming traffic. Port 8080 is open in the party cluster. If you need to change the application port, change it to one of the ports that are open in the party cluster.
Publish the application by using Visual Studio
Now that the application is ready, you can deploy it to a cluster directly from Visual Studio.
Right-click Voting in the Solution Explorer. Choose Publish. The Publish dialog box appears.
Copy the Connection Endpoint from either the party cluster page or your Azure subscription into the Connection Endpoint field. An example is
zwin7fh14scd.westus.cloudapp.azure.com:19000. Select Advanced Connection Parameters. Make sure that the FindValue and ServerCertThumbprint values match the thumbprint of the certificate installed in a previous step for a party cluster or the certificate that matches your Azure subscription.
Each application in the cluster must have a unique name. Party clusters are a public, shared environment, so there might be a conflict with an existing application. If there's a name conflict, rename the Visual Studio project and deploy it again.
To get to your voting application in the cluster, open a browser and enter the cluster address followed by :8080. Or enter another port if one is configured. An example is
http://zwin7fh14scd.westus.cloudapp.azure.com:8080. You see the application running in the cluster in Azure. In the voting web page, try adding and deleting voting options and voting for one or more of these options.
Advance to the next tutorial: