Share via


FabricClient.HealthClient.GetDeployedServicePackageHealthAsync Method

Definition

Overloads

GetDeployedServicePackageHealthAsync(Uri, String, String, ApplicationHealthPolicy, TimeSpan, CancellationToken)

Asynchronously gets the health of a deployed Service Fabric service package by using the specified timeout and cancellation token.

GetDeployedServicePackageHealthAsync(Uri, String, String, ApplicationHealthPolicy)

Asynchronously gets the health of a deployed Service Fabric service package.

GetDeployedServicePackageHealthAsync(Uri, String, String, TimeSpan, CancellationToken)

Asynchronously gets the health of a deployed Service Fabric service package by using the specified timeout and cancellation token.

GetDeployedServicePackageHealthAsync(DeployedServicePackageHealthQueryDescription, TimeSpan, CancellationToken)

Asynchronously gets the health of a deployed Service Fabric service package by using the specified timeout and cancellation token.

GetDeployedServicePackageHealthAsync(Uri, String, String)

Asynchronously gets the health of a deployed Service Fabric service package.

GetDeployedServicePackageHealthAsync(DeployedServicePackageHealthQueryDescription)

Asynchronously gets the health of a deployed Service Fabric service package by using the specified timeout and cancellation token.

GetDeployedServicePackageHealthAsync(Uri, String, String, ApplicationHealthPolicy, TimeSpan, CancellationToken)

Asynchronously gets the health of a deployed Service Fabric service package by using the specified timeout and cancellation token.

public System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth> GetDeployedServicePackageHealthAsync (Uri applicationName, string serviceManifestName, string nodeName, System.Fabric.Health.ApplicationHealthPolicy healthPolicy, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetDeployedServicePackageHealthAsync : Uri * string * string * System.Fabric.Health.ApplicationHealthPolicy * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth>
Public Function GetDeployedServicePackageHealthAsync (applicationName As Uri, serviceManifestName As String, nodeName As String, healthPolicy As ApplicationHealthPolicy, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of DeployedServicePackageHealth)

Parameters

applicationName
Uri

The URI of the Service Fabric application.

serviceManifestName
String

The name of the service manifest file for this Service Fabric service.

nodeName
String

The name of the node that the Service Fabric service was deployed to.

healthPolicy
ApplicationHealthPolicy

The application health policy used to evaluate entity health.

timeout
TimeSpan

The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

cancellationToken
CancellationToken

The optional cancellation token that the operation is observing. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation may still be completed even if it is canceled.

Returns

The health of a deployed Service Fabric service package.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the user provided timeout to complete.

Caused by one of the following:

FabricHealthEntityNotFound.

InvalidNameUri is returned when applicationName is not a valid Service Fabric Name.

CommunicationError is returned when a communication error caused the operation to fail.

InvalidCredentialType.

InvalidX509FindType.

InvalidX509StoreLocation.

InvalidX509StoreName.

InvalidX509Thumbprint.

InvalidProtectionLevel.

InvalidX509Store.

InvalidSubjectName.

InvalidAllowedCommonNameList.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to

GetDeployedServicePackageHealthAsync(Uri, String, String, ApplicationHealthPolicy)

Asynchronously gets the health of a deployed Service Fabric service package.

public System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth> GetDeployedServicePackageHealthAsync (Uri applicationName, string serviceManifestName, string nodeName, System.Fabric.Health.ApplicationHealthPolicy healthPolicy);
member this.GetDeployedServicePackageHealthAsync : Uri * string * string * System.Fabric.Health.ApplicationHealthPolicy -> System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth>
Public Function GetDeployedServicePackageHealthAsync (applicationName As Uri, serviceManifestName As String, nodeName As String, healthPolicy As ApplicationHealthPolicy) As Task(Of DeployedServicePackageHealth)

Parameters

applicationName
Uri

The URI of the Service Fabric application.

serviceManifestName
String

The name of the service manifest file for this Service Fabric service.

nodeName
String

The name of the node that the Service Fabric service was deployed to.

healthPolicy
ApplicationHealthPolicy

The application health policy used to evaluate the entity health.

Returns

The health of a deployed Service Fabric service package.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the specified time to complete.

Caused by one of the following:

FabricHealthEntityNotFound.

InvalidNameUri is returned when applicationName is not a valid Service Fabric Name.

CommunicationError is returned when a communication error caused the operation to fail.

InvalidCredentialType.

InvalidX509FindType.

InvalidX509StoreLocation.

InvalidX509StoreName.

InvalidX509Thumbprint.

InvalidProtectionLevel.

InvalidX509Store.

InvalidSubjectName.

InvalidAllowedCommonNameList.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to

GetDeployedServicePackageHealthAsync(Uri, String, String, TimeSpan, CancellationToken)

Asynchronously gets the health of a deployed Service Fabric service package by using the specified timeout and cancellation token.

public System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth> GetDeployedServicePackageHealthAsync (Uri applicationName, string serviceManifestName, string nodeName, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetDeployedServicePackageHealthAsync : Uri * string * string * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth>
Public Function GetDeployedServicePackageHealthAsync (applicationName As Uri, serviceManifestName As String, nodeName As String, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of DeployedServicePackageHealth)

Parameters

applicationName
Uri

The URI of the Service Fabric application.

serviceManifestName
String

The name of the service manifest file for this Service Fabric service.

nodeName
String

The name of the node that the Service Fabric service was deployed to.

timeout
TimeSpan

The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

cancellationToken
CancellationToken

The optional cancellation token that the operation is observing. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation may still be completed even if it is canceled.

Returns

The health of a deployed Service Fabric service package.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the user provided timeout to complete.

Caused by one of the following:

FabricHealthEntityNotFound.

InvalidNameUri is returned when applicationName is not a valid Service Fabric Name.

CommunicationError is returned when a communication error caused the operation to fail.

InvalidCredentialType.

InvalidX509FindType.

InvalidX509StoreLocation.

InvalidX509StoreName.

InvalidX509Thumbprint.

InvalidProtectionLevel.

InvalidX509Store.

InvalidSubjectName.

InvalidAllowedCommonNameList.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to

GetDeployedServicePackageHealthAsync(DeployedServicePackageHealthQueryDescription, TimeSpan, CancellationToken)

Asynchronously gets the health of a deployed Service Fabric service package by using the specified timeout and cancellation token.

public System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth> GetDeployedServicePackageHealthAsync (System.Fabric.Description.DeployedServicePackageHealthQueryDescription queryDescription, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetDeployedServicePackageHealthAsync : System.Fabric.Description.DeployedServicePackageHealthQueryDescription * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth>
Public Function GetDeployedServicePackageHealthAsync (queryDescription As DeployedServicePackageHealthQueryDescription, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of DeployedServicePackageHealth)

Parameters

queryDescription
DeployedServicePackageHealthQueryDescription

The query description.

timeout
TimeSpan

The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

cancellationToken
CancellationToken

The optional cancellation token that the operation is observing. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation may still be completed even if it is canceled.

Returns

The health of a deployed Service Fabric service package.

Exceptions

Caused by one of the following:

FabricHealthEntityNotFound.

InvalidNameUri is returned when ApplicationName is not a valid Service Fabric Name.

See also https://docs.microsoft.com/azure/service-fabric/service-fabric-errors-and-exceptions for handling common FabricClient failures.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to

GetDeployedServicePackageHealthAsync(Uri, String, String)

Asynchronously gets the health of a deployed Service Fabric service package.

public System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth> GetDeployedServicePackageHealthAsync (Uri applicationName, string serviceManifestName, string nodeName);
member this.GetDeployedServicePackageHealthAsync : Uri * string * string -> System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth>
Public Function GetDeployedServicePackageHealthAsync (applicationName As Uri, serviceManifestName As String, nodeName As String) As Task(Of DeployedServicePackageHealth)

Parameters

applicationName
Uri

The URI of the Service Fabric application.

serviceManifestName
String

The name of the service manifest file for this Service Fabric service.

nodeName
String

The name of the node that the Service Fabric service was deployed to.

Returns

The health of a deployed Service Fabric service package.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the specified time to complete.

Caused by one of the following:

FabricHealthEntityNotFound.

InvalidNameUri is returned when applicationName is not a valid Service Fabric Name.

CommunicationError is returned when a communication error caused the operation to fail.

InvalidCredentialType.

InvalidX509FindType.

InvalidX509StoreLocation.

InvalidX509StoreName.

InvalidX509Thumbprint.

InvalidProtectionLevel.

InvalidX509Store.

InvalidSubjectName.

InvalidAllowedCommonNameList.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Remarks

The following example gets the health of a deployed service package.

public static bool GetDeployedServicePackageHealth(string clusterConnection)
            {
                DeployedApplicationHealth deployedApplicationHealth;
                DeployedServicePackageHealth deployedServicePackageHealth;
                ApplicationHealth applicationHealth;
                Uri applicationName = new Uri("fabric:/myapp/todo");

                // Connect to the cluster.
                FabricClient fabricClient = new FabricClient(clusterConnection);

                Console.WriteLine("Deployed Service Package Health:");

                try
                {
                    // Determine the nodes where the application has been deployed.
                    applicationHealth = fabricClient.HealthManager.GetApplicationHealthAsync(applicationName).Result;

                    // Get the deployed service package health for each node.
                    IList<DeployedApplicationHealthState> deployedApplicationHealthStateList = applicationHealth.DeployedApplicationHealthStates;
                    foreach (DeployedApplicationHealthState deployedApplicationHealthState in deployedApplicationHealthStateList)
                    {
            // Get the deployed application health, which contains the service manifest name and 
            // the names of the nodes where the service has been deployed.
            deployedApplicationHealth = fabricClient.HealthManager.GetDeployedApplicationHealthAsync(applicationName,
                deployedApplicationHealthState.NodeName).Result;

            // Return if empty.
            if (deployedApplicationHealth.DeployedServicePackageHealthStates.Count == 0)
                return false;

            // Get the deployed service package health.
            deployedServicePackageHealth = fabricClient.HealthManager.GetDeployedServicePackageHealthAsync(applicationName,
                deployedApplicationHealth.DeployedServicePackageHealthStates[0].ServiceManifestName, 
                deployedApplicationHealthState.NodeName).Result;

            // Display the deployed service package health information.
            Console.WriteLine("  Application Name: " + deployedServicePackageHealth.ApplicationName);
            Console.WriteLine("    Node Name: " + deployedServicePackageHealth.NodeName);
            Console.WriteLine("    Aggregated Health State: " + deployedServicePackageHealth.AggregatedHealthState);
            Console.WriteLine("    Service Manifest Name: " + deployedServicePackageHealth.ServiceManifestName);

            // List the health events.
            Console.WriteLine("    Health Events:");
            IList<HealthEvent> healthEvents = deployedServicePackageHealth.HealthEvents;
            foreach (HealthEvent healthEvent in healthEvents)
            {
                Console.WriteLine("      Health Event:");
                Console.WriteLine("        Last Modified: " + healthEvent.LastModifiedUtcTimestamp);
                Console.WriteLine("        Source UTC Timestamp: " + healthEvent.SourceUtcTimestamp);
                Console.WriteLine("        Is Expired: " + healthEvent.IsExpired);
                Console.WriteLine("        Health Information:");
                Console.WriteLine("          Description: " + healthEvent.HealthInformation.Description);
                Console.WriteLine("          Source ID: " + healthEvent.HealthInformation.SourceId);
                Console.WriteLine("          Health State: " + healthEvent.HealthInformation.HealthState);
                Console.WriteLine("          Property: " + healthEvent.HealthInformation.Property);
                Console.WriteLine("          Remove When Expired: " + healthEvent.HealthInformation.RemoveWhenExpired);
                Console.WriteLine("          Sequence Number: " + healthEvent.HealthInformation.SequenceNumber);
                Console.WriteLine("          Time to Live: " + healthEvent.HealthInformation.TimeToLive);
            }

            // List the unhealthy evaluations.
            Console.WriteLine("    Unhealthy Evaluations:");
            IList<HealthEvaluation> healthEvaluationList = deployedServicePackageHealth.UnhealthyEvaluations;
            foreach (HealthEvaluation healthEvaluation in healthEvaluationList)
            {
                Console.WriteLine("      Kind: " + healthEvaluation.Kind);
                Console.WriteLine("        Aggregated Health State: " + healthEvaluation.AggregatedHealthState);
                Console.WriteLine("        Description: " + healthEvaluation.Description);
            }

            Console.WriteLine();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);

                    if (e.InnerException != null)
            Console.WriteLine("  Inner Exception: " + e.InnerException.Message);

                    return false;
                }
                return true;
            }

Applies to

GetDeployedServicePackageHealthAsync(DeployedServicePackageHealthQueryDescription)

Asynchronously gets the health of a deployed Service Fabric service package by using the specified timeout and cancellation token.

public System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth> GetDeployedServicePackageHealthAsync (System.Fabric.Description.DeployedServicePackageHealthQueryDescription queryDescription);
member this.GetDeployedServicePackageHealthAsync : System.Fabric.Description.DeployedServicePackageHealthQueryDescription -> System.Threading.Tasks.Task<System.Fabric.Health.DeployedServicePackageHealth>
Public Function GetDeployedServicePackageHealthAsync (queryDescription As DeployedServicePackageHealthQueryDescription) As Task(Of DeployedServicePackageHealth)

Parameters

queryDescription
DeployedServicePackageHealthQueryDescription

The query description.

Returns

The health of a deployed Service Fabric service package.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the specified time to complete.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to