Search code examples
powershellserverazure-resource-managerazure-rm-templateazure-storage-files

Is there a way to get the server ID of the registered server in an Azure storage sync service through power shell or ARM template?


{
  "name": "string",
  "type": "Microsoft.StorageSync/storageSyncServices/syncGroups/serverEndpoints",
  "apiVersion": "2019-06-01",
  "properties": {
    "serverLocalPath": "string",
    "cloudTiering": "string",
    "volumeFreeSpacePercent": "integer",
    "tierFilesOlderThanDays": "integer",
    "friendlyName": "string",
    "serverResourceId": "string",
    "offlineDataTransfer": "string",
    "offlineDataTransferShareName": "string"
  }
}

What needs to be passed as a server resource id in the above template format for storage sync. How do we get the server id ?


Solution

  • Yes. Use the Get-AzStorageSyncServerEndpoint cmdlet from the Az.StorageSync module to list all server endpoints within a given sync group.

    Get-AzStorageSyncServerEndpoint -ResourceGroupName "myResourceGroup" -StorageSyncServiceName "mysyncservice" -SyncGroupName "testsyncgroup"
    

    Sample Response:

    SyncGroupName                               : testsyncgroup
    StorageSyncServiceName                      : mysyncservice
    ServerLocalPath                             : C:\Users\onpremwindows\Desktop\myfolder
    ServerResourceId                            : /subscriptions/***/resourceGroups/myResourceGroup/providers/microsoft.stor
                                                  agesync/storageSyncServices/mysyncservice/registeredServers/8ec8b78c-0739-195r-856e-2e7r5ta2c13w
    ServerEndpointName                          : 94e9fd59-23d6-9854-99c1-3e9a8ab73760
    ProvisioningState                           : Succeeded
    LastWorkflowId                              : storageSyncServices/mysyncservice/workflows/bd3o8c77-7183-4a46-8830-9b156dd2f011
    LastOperationName                           : ICreateServerEndpointWorkflow
    FriendlyName                                : onpremwindows
    SyncStatus                                  : Microsoft.Azure.Commands.StorageSync.Models.PSServerEndpointHealth
    CloudTiering                                : Off
    VolumeFreeSpacePercent                      : 20
    TierFilesOlderThanDays                      :
    OfflineDataTransfer                         : Off
    OfflineDataTransferShareName                :
    OfflineDataTransferStorageAccountResourceId :
    OfflineDataTransferStorageAccountTenantId   :
    InitialDownloadPolicy                       : NamespaceThenModifiedFiles
    LocalCacheMode                              : UpdateLocallyCachedFiles
    ResourceId                                  : /subscriptions/***/resourceGroups/myResourceGroup/providers/microsoft.stor
                                                  agesync/storageSyncServices/mysyncservice/syncGroups/testsyncgroup/serverEndpoints/94e9fd59-23d6-9854-99c1-3e9a8ab73760
    ResourceGroupName                           : myResourceGroup
    Type                                        : microsoft.storagesync/storageSyncServices/syncGroups/serverEndpoints
    

    8ec8b78c-0739-195r-856e-2e7r5ta2c13w would be the ServerId you can pass.

    You can obtain the ServerId using the Get-AzStorageSyncService cmdlet as well:

    Get-AzStorageSyncService -ResourceGroupName "myResourceGroup" -StorageSyncServiceName "mysyncservice"
    

    Sample response:

    StorageSyncServiceName    : mysyncservice
    ServerName                : 8ec8b78c-0739-195r-856e-2e7r5ta2c13w
    ServerCertificate         :
    AgentVersion              : 8.0.0.0
    ServerOSVersion           : 10.0.14393.0
    ServerManagementErrorCode : 0
    LastHeartBeat             : 12/10/2019 12:55:01
    ProvisioningState         : Succeeded
    ServerRole                : Standalone
    ClusterId                 : 00000000-0000-0000-0000-000000000000
    ClusterName               :
    ServerId                  : 8ec8b78c-0739-195r-856e-2e7r5ta2c13w
    StorageSyncServiceUid     : 76104503-6cd8-4812-7884-c4288e87a8cd
    LastWorkflowId            : storageSyncServices/finalsync/workflows/0e3bc737-7619-4b42-81a9-aec36e3fbf53
    LastOperationName         : ICreateRegisteredServerWorkflow
    DiscoveryEndpointUri      : https://tm-server.xxx.com:443
    ResourceLocation          : eastasia
    ServiceLocation           : eastasia
    FriendlyName              : onpremwindows
    ManagementEndpointUri     : https://tm-server.xxx.com:443
    MonitoringEndpointUri     : https://tm-server.xxx.com:443
    ResourceId                : /subscriptions/***/resourceGroups/myResourceGroup/providers/microsoft.storagesync/storageSyncServices/mysyncservice/registeredServers/8ec8b78c-0739-195r-856e-2e7r5ta2c13w
    ResourceGroupName         : myResourceGroup
    Type                      : microsoft.storagesync/storageSyncServices/registeredServers