Deploy, monitor, and debug Service Fabric apps—build/deploy to local or remote clusters, check health and logs, query SQL databases, and view configurations.
This skill supports deploying Service Fabric applications to both local development clusters and remote Azure clusters with AAD authentication.
| Scenario | What You Need | Jump To |
|---|---|---|
| Deploy to Local | Deploy an SF app to local cluster | Deployment Workflow |
| Deploy to Remote | Deploy to Azure cluster with AAD auth | Remote Deployment |
| Troubleshoot Only | Debug a running app (already deployed) | Troubleshooting Tools |
| Deploy + Troubleshoot | Iterate on code with build-deploy-test cycle | Quick Commands |
Trigger: User wants to:
IMPORTANT: Use the sf.ps1 script from the user profile skills directory based on which agent you are by replacing the token [REPLACE_ME] with the appropriate path:
$scriptPath = "~\.roo\skills\service-fabric\scripts\sf.ps1"$scriptPath = "~\.copilot\skills\service-fabric\scripts\sf.ps1"/t:Package targetAsk the user which application to deploy if not specified. Available applications:
| Application | Description |
|---|---|
SonarCoreApplication | Core services (BlobService, QueueService) |
PlatformApplication | Platform services |
PlatformMonitorApplication | Platform monitoring |
SonarArchiveApplication | Archive services |
SonarDetonationApplication | Detonation services |
SonarExportApplication | Export services |
SonarFeedApplication | Feed services |
SonarRepairApplication | Repair services |
SslCertificateMonitorApplication | SSL certificate monitoring |
ToolsetApplication | Toolset services |
AzureVmDetonationApplication | Azure VM detonation services |
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath deploy <ApplicationName>"
To build the package only (without deploying):
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath build <ApplicationName>"
The script automatically verifies services are ready. You can also check:
Get-ServiceFabricApplication -ApplicationName "fabric:/<ApplicationName>"To deploy to a remote Azure cluster, use the -PublishProfile parameter with a cluster-specific profile:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath deploy <ApplicationName> -PublishProfile <ClusterProfile>.xml"
The script will:
Available publish profiles are located in each application's PublishProfiles folder (e.g., Deployment\SonarCoreApplication\PublishProfiles\).
Deploy to local cluster (default):
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath deploy SonarCoreApplication"
Deploy to remote cluster:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath deploy SonarCoreApplication -PublishProfile anz-ds5-dev-us-wus2-1.xml"
Build only (no deploy):
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath build PlatformApplication"
Remove application from cluster:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath remove ToolsetApplication"
All cluster commands are available through the sf.ps1 script, which handles cluster connection automatically. Run all commands from the repo root directory.
List all applications:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath apps"
Remove application:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath remove <ApplicationName>"
List services in an application:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath services <ApplicationName>"
Get application health summary:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath health <ApplicationName>"
Get service health:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath health <ApplicationName> <ServiceName>"
List cluster nodes:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath nodes"
Get cluster health:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath cluster-health"
Services use local SQL Server databases. Connection strings are in appsettings.local.json or ENV-local section in Settings.xml:
| Service | Database | Config Key |
|---|---|---|
| QueueService2 | SonarQueue | QueueDatabase |
| BlobService2 | SonarBlob | BlobDatabase |
| ConfigurationService | SonarConfiguration | via config |
| FrontendService | SonarFrontend | via config |
List all Sonar databases:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-list"
List tables in a database:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-tables <DatabaseName>"
Get table schema (columns and types):
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-schema <DatabaseName> <TableName>"
List stored procedures:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-procs <DatabaseName>"
View stored procedure code:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-proc-code <DatabaseName> <ProcedureName>"
Execute SQL query:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-query <DatabaseName> '<SQL Query>'"
SonarQueue - View queue messages:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-query SonarQueue 'SELECT MessageId, QueueName, State, Label, LEN(Data) as DataLen FROM dbo.Message ORDER BY MessageId DESC'"
SonarQueue - View messages in specific queue:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-query SonarQueue 'SELECT MessageId, State, DequeueCount, Label FROM dbo.Message WHERE QueueName = ''<QueueName>'' ORDER BY MessageId'"
SonarBlob - View blob metadata:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath db-query SonarBlob 'SELECT TOP 10 BlobName, Length, LastUpdateDate FROM dbo.Blob ORDER BY LastUpdateDate DESC'"
| Log Type | Location |
|---|---|
| Sonar application logs | C:\SonarLogs\ |
| SF application work folder | C:\SfDevCluster\Data\_App\_Node_0\<AppTypeName>_App<N>\ |
| Service Fabric system logs | C:\SfDevCluster\Log\Traces\ |
| ETW traces | C:\SfDevCluster\Log\Traces\*.etl |
View recent logs for a service:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath logs <ServiceName>"
View with custom tail count:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath logs <ServiceName> 100"
Search logs for pattern:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath logs-search <ServiceName> '<Pattern>'"
Search for errors in logs:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath logs-errors <ServiceName>"
Watch logs in real-time:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath logs-watch <ServiceName>"
View .NET Runtime errors:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath events"
View Service Fabric events:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath sf-events"
Filter events by application:
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath sf-events <ApplicationName>"
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath deploy <AppName>"
View service configuration (appsettings.local.json and Settings.xml):
pwsh -Command "$scriptPath = [REPLACE_ME]; & $scriptPath config <ServiceName>"
| Issue | Solution |
|---|---|
| Cluster not running | Start via Service Fabric Local Cluster Manager (system tray) |
| Package not found | Build with msbuild /t:Package /p:Configuration=Release /p:Platform=x64 |
| Services not starting | Check C:\SonarLogs and Event Log for errors |
| Connection refused | Ensure local cluster is running on port 19080 |
| Service crashes | Check Get-EventLog -LogName Application -EntryType Error |
| Missing dependencies | Verify all NuGet packages restored, rebuild package |
| Database errors | Use sqlcmd to verify database exists and is accessible |
sf.ps1 - Unified management script. Run without arguments for help.Deploy-ServiceFabricApplication.ps1 - Underlying deployment script (supports local and remote clusters)C:\SonarLogs\ - Sonar application logsC:\SfDevCluster\ - Local SF cluster data and logs