Deploying a Sample Application to Service Fabric
Deploying a Sample Application to Service Fabric
Now that your cluster is running and you understand how to monitor it, it’s time to deploy a real application to Service Fabric! In this tutorial, we'll deploy a simple sample app to your local or Azure-hosted cluster.
🛠️ What We'll Cover
- Create a sample Service Fabric application in Visual Studio.
- Package and deploy it to a local or Azure cluster.
- Monitor the app through Service Fabric Explorer.
🚀 Step-by-Step Deployment Guide
Step 1: Create a New Service Fabric Application
- Open Visual Studio (as Administrator is preferred).
- Go to File → New → Project.
- Search for "Service Fabric Application" and select it.
- Click Next.
- Name your project (e.g.,
SampleAppFabric
). - Choose the location and solution name.
- Click Create.
Step 2: Choose Application Template
Visual Studio will now prompt you to choose a service type:
- Select Stateless ASP.NET Core Web API for this example.
- Click OK.
Step 3: Review Solution Structure
Visual Studio will generate:
- Application Project (.sfproj)
- Service Project (ASP.NET Core Web API project)
- ApplicationManifest.xml and ServiceManifest.xml for packaging and deployment.
Step 4: Package the Application
Visual Studio handles packaging automatically when you build the application.
If you want to manually package, right-click the application project and select:
Publish → Create Package Only
Step 5: Deploy to Cluster
- Right-click the Application project (the one with .sfproj).
- Click Publish.
-
In the Publish wizard:
- Select Local Cluster or Azure Cluster.
- If targeting Azure, make sure cluster certificate and credentials are handled properly.
- Click Publish.
Step 6: Monitor Deployment
Once published, open Service Fabric Explorer:
- You will see the application under the Applications section.
- Expand it to see deployed services, partitions, and instances.
Step 7: Test Your Web API
If you deployed a Web API service:
- Right-click the running service instance → Get HTTP endpoint details.
- Open the URL in a browser — you should see your API live!
📈 Visual Flow
[Create Project] → [Choose Template] → [Package App] → [Publish to Cluster] → [Monitor via Explorer] → [Test App Endpoint]
💡 Did You Know?
You can deploy multiple versions of the same application simultaneously by using different Application Names during publish!
⚡ Common Beginner Issues and Solutions
-
Problem: Deployment failed due to certificate errors.
Solution: For local cluster, ensure no certificates needed. For Azure, configure security settings properly. -
Problem: Service stuck in 'Upgrading'.
Solution: Reset the application upgrade from Service Fabric Explorer or PowerShell. -
Problem: Service keeps restarting.
Solution: Check logs and exceptions inside the deployed service — use Event Viewer or Application Insights integration.
🚨 Important Best Practices
- Always build and test your application locally first before publishing to Azure.
- Use meaningful names for services and applications for easy identification.
- Monitor deployed applications regularly to catch failures early.
✅ Final Deployment Checklist
- Sample application created ✔️
- Successfully deployed to local or Azure cluster ✔️
- Service visible and healthy in Service Fabric Explorer ✔️
- Web API endpoint working ✔️
✅ Self-Check Quiz
- Which project type should you select to create a Stateless Web API?
- What must you verify before publishing to an Azure cluster?
- Where can you find service instances and partitions after deployment?