Share via


ResourceNotificationService.TryGetCurrentState(String, ResourceEvent) Method

Definition

Attempts to retrieve the current state of a resource by resourceId.

public bool TryGetCurrentState(string resourceId, out Aspire.Hosting.ApplicationModel.ResourceEvent? resourceEvent);
member this.TryGetCurrentState : string * ResourceEvent -> bool
Public Function TryGetCurrentState (resourceId As String, ByRef resourceEvent As ResourceEvent) As Boolean

Parameters

resourceId
String

The resource id. This id can either exactly match the unique id of the resource or the displayed resource name if the resource name doesn't have duplicates (i.e. replicas).

resourceEvent
ResourceEvent

When this method returns, contains the ResourceEvent for the specified resource id, if found; otherwise, null.

Returns

true if specified resource id was found; otherwise, false.

Remarks

A resource id can be either the unique id of the resource or the displayed resource name.

Projects, executables and containers typically have a unique id that combines the display name and a unique suffix. For example, a resource named cache could have a resource id of cache-abcdwxyz. This id is used to uniquely identify the resource in the app host.

The resource name can be also be used to retrieve the resource state, but it must be unique. If there are multiple resources with the same name, then this method will not return a match. For example, if a resource named cache has multiple replicas, then specifing cache won't return a match.

Applies to