You can deploy a Service Fabric application using an ARM templat with a number very different mechanisms, whichever you’d like:
But first you need the actual ARM template. Here’s an example of an application consisting of one stateless service (the frontend) and one stateful service (the backend):
{
"$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The Azure region where the cluster is located."
}
},
"clusterName": {
"type": "string",
"metadata": {
"description": "Name of your cluster - Between 3 and 23 characters. Letters and numbers only."
}
},
"appPackageUrl": {
"type": "string",
"metadata": {
"description": "The URL to the application package sfpkg file."
}
},
"applicationName": {
"type": "string",
"defaultValue": "MyApplication",
"metadata": {
"description": "The application name."
}
},
"applicationTypeName": {
"type": "string",
"defaultValue": "MyApplicationType",
"metadata": {
"description": "The application type name."
}
},
"applicationTypeVersion": {
"type": "string",
"metadata": {
"description": "The application type version."
}
},
"applicationParameters": {
"type": "object",
"metadata": {
"description": "Application parameters override to be applied when creating or upgrading an application."
},
"defaultValue": {
"MyStatelessService_PlacementConstraints": "[parameters('MyStatelessService_PlacementConstraints')]",
"MyStatelessService_InstanceCount": "[parameters('MyStatelessService_InstanceCount')]",
"MyStatefulService_PlacementConstraints": "[parameters('MyStatefulService_PlacementConstraints')]",
"MyStatefulService_TargetReplicaSetSize": "[parameters('MyStatefulService_TargetReplicaSetSize')]",
"MyStatefulService_MinReplicaSetSize": "[parameters('MyStatefulService_MinReplicaSetSize')]",
"MyStatefulService_PartitionCount": "[parameters('MyStatefulService_PartitionCount')]"
}
},
"MyStatelessService_PlacementConstraints": {
"type": "string"
},
"MyStatelessService_InstanceCount": {
"type": "int",
"defaultValue": -1
},
"MyStatefulService_PlacementConstraints": {
"type": "string"
},
"MyStatefulService_TargetReplicaSetSize": {
"type": "int"
},
"MyStatefulService_MinReplicaSetSize": {
"type": "int"
},
"MyStatefulService_PartitionCount": {
"type": "int"
}
},
"variables": {
"sfApiVersion": "2021-06-01"
},
"resources": [
{
"name": "[format('{0}/{1}', parameters('clusterName'), parameters('applicationTypeName'))]",
"apiVersion": "[variables('sfApiVersion')]",
"type": "Microsoft.ServiceFabric/clusters/applicationTypes",
"location": "[parameters('location')]",
"properties": {
},
"dependsOn": []
},
{
"name": "[format('{0}/{1}/{2}', parameters('clusterName'), parameters('applicationTypeName'), parameters('applicationTypeVersion'))]",
"apiVersion": "[variables('sfApiVersion')]",
"type": "Microsoft.ServiceFabric/clusters/applicationTypes/versions",
"location": "[parameters('location')]",
"properties": {
"appPackageUrl": "[parameters('appPackageUrl')]"
},
"dependsOn": [
"[concat('Microsoft.ServiceFabric/clusters/', parameters('clusterName'), '/applicationTypes/', parameters('applicationTypeName'))]"
]
},
{
"name": "[format('{0}/{1}', parameters('clusterName'), parameters('applicationName'))]",
"apiVersion": "[variables('sfApiVersion')]",
"type": "Microsoft.ServiceFabric/clusters/applications",
"location": "[parameters('location')]",
"properties": {
"typeName": "[parameters('applicationTypeName')]",
"typeVersion": "[parameters('applicationTypeVersion')]",
"parameters": "[parameters('applicationParameters')]",
"upgradePolicy": {
"upgradeReplicaSetCheckTimeout": "01:00:00.0",
"forceRestart": true,
"rollingUpgradeMonitoringPolicy": {
"healthCheckWaitDuration": "00:02:00.0",
"healthCheckStableDuration": "00:05:00.0",
"healthCheckRetryTimeout": "00:10:00.0",
"upgradeTimeout": "01:00:00.0",
"upgradeDomainTimeout": "00:20:00.0"
},
"applicationHealthPolicy": {
"considerWarningAsError": false,
"maxPercentUnhealthyDeployedApplications": 0,
"defaultServiceTypeHealthPolicy": {
"maxPercentUnhealthyServices": 0,
"maxPercentUnhealthyPartitionsPerService": 0,
"maxPercentUnhealthyReplicasPerPartition": 0
}
}
}
},
"dependsOn": [
"[concat('Microsoft.ServiceFabric/clusters/', parameters('clusterName'), '/applicationTypes/', parameters('applicationTypeName'), '/versions/', parameters('applicationTypeVersion'))]"
]
},
{
"name": "[format('{0}/{1}/{1}~{2}', parameters('clusterName'), parameters('applicationName'), 'MyStatelessService')]",
"apiVersion": "[variables('sfApiVersion')]",
"type": "Microsoft.ServiceFabric/clusters/applications/services",
"location": "[parameters('location')]",
"properties": {
"serviceKind": "Stateless",
"correlationScheme": [],
"serviceLoadMetrics": [],
"servicePlacementPolicies": [],
"serviceTypeName": "MyStatelessServiceType",
"placementConstraints": "[parameters('MyStatelessService_PlacementConstraints')]",
"instanceCount": "[parameters('MyStatelessService_InstanceCount')]",
"partitionDescription": {
"partitionScheme": "Singleton"
}
},
"dependsOn": [
"[concat('Microsoft.ServiceFabric/clusters/', parameters('clusterName'), '/applications/', parameters('applicationName'))]"
]
},
{
"name": "[format('{0}/{1}/{1}~{2}', parameters('clusterName'), parameters('applicationName'), 'MyStatefulService')]",
"apiVersion": "[variables('sfApiVersion')]",
"type": "Microsoft.ServiceFabric/clusters/applications/services",
"location": "[parameters('location')]",
"properties": {
"serviceKind": "Stateful",
"serviceTypeName": "MyStatefulServiceType",
"placementConstraints": "[parameters('MyStatefulService_PlacementConstraints')]",
"hasPersistedState": true,
"defaultMoveCost": "Zero",
"replicaRestartWaitDuration": "00:01:00.0",
"quorumLossWaitDuration": "00:02:00.0",
"standByReplicaKeepDuration": "00:00:30.0",
"targetReplicaSetSize": "[parameters('MyStatefulService_TargetReplicaSetSize')]",
"minReplicaSetSize": "[parameters('MyStatefulService_MinReplicaSetSize')]",
"partitionDescription": {
"partitionScheme": "UniformInt64Range",
"count": "[parameters('MyStatefulService_PartitionCount')]",
"lowKey": "-9223372036854775808",
"highKey": "9223372036854775807"
}
},
"dependsOn": [
"[concat('Microsoft.ServiceFabric/clusters/', parameters('clusterName'), '/applications/', parameters('applicationName'))]"
]
}
]
}
Note that there is a number of different ways to get the latest API version for Service Fabric applications, such as: