private async Task <List <ReplicaMonitoringInfo> > GetDeployedPrimaryReplicaAsync(Uri appName, ServiceList services)
        {
            var deployedReplicaList = await this.FabricClientInstance.QueryManager.GetDeployedReplicaListAsync(this.NodeName, appName).ConfigureAwait(true);

            var replicaMonitoringList = new List <ReplicaMonitoringInfo>();

            foreach (var deployedReplica in deployedReplicaList)
            {
                if (deployedReplica is DeployedStatefulServiceReplica statefulReplica)
                {
                    if (statefulReplica.ReplicaRole == ReplicaRole.Primary &&
                        services.Any(s => s.ServiceName == statefulReplica.ServiceName))
                    {
                        var replicaInfo = new ReplicaMonitoringInfo()
                        {
                            ApplicationName      = appName,
                            ReplicaHostProcessId = statefulReplica.HostProcessId,
                            ReplicaOrInstanceId  = statefulReplica.ReplicaId,
                            Partitionid          = statefulReplica.Partitionid,
                        };

                        replicaMonitoringList.Add(replicaInfo);

                        continue;
                    }
                }

                if (deployedReplica is DeployedStatelessServiceInstance statelessReplica &&
                    services.Any(s => s.ServiceName == statelessReplica.ServiceName))
                {
                    var replicaInfo = new ReplicaMonitoringInfo()
                    {
                        ApplicationName      = appName,
                        ReplicaHostProcessId = statelessReplica.HostProcessId,
                        ReplicaOrInstanceId  = statelessReplica.InstanceId,
                        Partitionid          = statelessReplica.Partitionid,
                    };

                    replicaMonitoringList.Add(replicaInfo);

                    continue;
                }
            }

            return(replicaMonitoringList);
        }