Search code examples
jsonazureazure-devopsazure-rm-templateazure-storage-files

How do we pass the server ID to a server endpoint to a Storage sync aka file sync service through an ARM template


 *"type": "microsoft.storagesync/storageSyncServices/syncGroups/serverEndpoints"
    {
                "type": "microsoft.storagesync/storageSyncServices/registeredServers",
                "apiVersion": "2020-03-01",
                "name": "[concat(parameters('FilesyncName'), '/rs')]",
                "dependsOn": [
                    "[resourceId('microsoft.storagesync/storageSyncServices', parameters('FilesyncName'))]"
                ],
                "properties": {
                    "agentVersion": "XXXX",
                    "serverOSVersion": "XXXX",
                    "lastHeartBeat": "XXXXX",
                    "serverRole": "Standalone",
                    "clusterId": "XX",
                    "serverId": "XXXXX",
                    "friendlyName": "XXXXXXXX"
                }
            },
             {
                "type": "microsoft.storagesync/storageSyncServices/syncGroups/serverEndpoints",
                "apiVersion": "2020-03-01",
                "name": "[concat(parameters('FilesyncName'),'/',parameters('syncgroupname'),'/','-se')]", 
                "dependsOn": [
                    "[resourceId('microsoft.storagesync/storageSyncServices/syncGroups', parameters('FilesyncName'), parameters('syncgroupname'))]",
                    "[resourceId('microsoft.storagesync/storageSyncServices', parameters('FilesyncName'))]",
                    "[resourceId('microsoft.storagesync/storageSyncServices/registeredServers', parameters('FilesyncName'), 'rs')]"
                ],
                "properties": {
                    "serverLocalPath": "F:\\",
                    "cloudTiering": "On",
                    "volumeFreeSpacePercent": 20,
                    "tierFilesOlderThanDays": 7,
                    "friendlyName": "XXXX",
                    "serverResourceId": "[resourceId('microsoft.storagesync/storageSyncServices/registeredServers', parameters('FilesyncName'), 'rs')]",
                    "offlineDataTransfer": "On",
                    "offlineDataTransferShareName": "fsnew",
                    "initialDownloadPolicy": "NamespaceOnly",
                    "localCacheMode": "UpdateLocallyCachedFiles"
                }
            }*

The above resource type and the ARM TEMPLATE for adding the server end points. This template doesn't trigger the provisioning the server end-point. Would like to see an example of the same.TIA


Solution

  • The following is a working ARM template that deploys a Storage Sync Service, a Sync Group and a Server Endpoint.

    You can get the serverResourceId property when you register the server with your Storage sync server as described here, but in the ResourceId format:

    /subscriptions/***/resourceGroups/***/providers/microsoft.storagesync/storageSyncServices/mystoragesyncservice/registeredServers/85fa92da-2b2e-447c-d3rg-f8bf43c4064f
    
    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "storagesyncservicename": {
                "type": "string",
                "defaultValue": "mystoragesyncservice"
            }
        },
        "variables": {},
        "resources": [
            {
                "type": "microsoft.storagesync/storageSyncServices",
                "apiVersion": "2020-03-01",
                "name": "[parameters('storagesyncservicename')]",
                "location": "westus2",
                "properties": {
                    "incomingTrafficPolicy": "AllowAllTraffic"
                }
            },
            {
                "type": "microsoft.storagesync/storageSyncServices/syncGroups",
                "apiVersion": "2020-03-01",
                "name": "[concat(parameters('storagesyncservicename'), '/mystoragesyncgroup')]",
                "dependsOn": [
                    "[resourceId('microsoft.storagesync/storageSyncServices', parameters('storagesyncservicename'))]"
                ],
                "properties": {}
            },
            {
                "type": "microsoft.storagesync/storageSyncServices/syncGroups/serverEndpoints",
                "apiVersion": "2020-03-01",
                "name": "[concat(parameters('storagesyncservicename'), '/mystoragesyncgroup/5770750b-a1e6-4910-9781-1482fdee757a')]",
                "dependsOn": [
                    "[resourceId('microsoft.storagesync/storageSyncServices/syncGroups', parameters('storagesyncservicename'), 'mystoragesyncgroup')]",
                    "[resourceId('microsoft.storagesync/storageSyncServices', parameters('storagesyncservicename'))]"
                ],
                "properties": {
                    "serverLocalPath": "D:\\Data",
                    "cloudTiering": "Off",
                    "volumeFreeSpacePercent": 20,
                    "friendlyName": "mytestafs",
                    "serverResourceId": "/subscriptions/***/resourceGroups/***/providers/microsoft.storagesync/storageSyncServices/mystoragesyncservice/registeredServers/85fa92da-2b2e-447c-d3rg-f8bf43c4064f",
                    "offlineDataTransfer": "Off",
                    "initialDownloadPolicy": "NamespaceThenModifiedFiles",
                    "localCacheMode": "UpdateLocallyCachedFiles"
                }
            }
        ]
    }