Partager via


DeploymentEnvironmentsClient.GetEnvironmentsAsync Method

Definition

Overloads

GetEnvironmentsAsync(String, String, RequestContext)

[Protocol Method] Lists the environments for a project and user.

GetEnvironmentsAsync(String, String, CancellationToken)

Lists the environments for a project and user.

GetEnvironmentsAsync(String, String, Nullable<Int32>, RequestContext)

[Protocol Method] Lists the environments for a project and user.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.

GetEnvironmentsAsync(String, String, RequestContext)

Source:
DeploymentEnvironmentsClient.cs

[Protocol Method] Lists the environments for a project and user.

public virtual Azure.AsyncPageable<BinaryData> GetEnvironmentsAsync (string projectName, string userId, Azure.RequestContext context);
abstract member GetEnvironmentsAsync : string * string * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
override this.GetEnvironmentsAsync : string * string * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
Public Overridable Function GetEnvironmentsAsync (projectName As String, userId As String, context As RequestContext) As AsyncPageable(Of BinaryData)

Parameters

projectName
String

The DevCenter Project upon which to execute operations.

userId
String

The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The AsyncPageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.

Exceptions

projectName or userId is null.

projectName or userId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call GetEnvironmentsAsync and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);

await foreach (BinaryData item in client.GetEnvironmentsAsync("<projectName>", "<userId>", null))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("name").ToString());
    Console.WriteLine(result.GetProperty("environmentType").ToString());
    Console.WriteLine(result.GetProperty("catalogName").ToString());
    Console.WriteLine(result.GetProperty("environmentDefinitionName").ToString());
}

This sample shows how to call GetEnvironmentsAsync with all parameters and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);

await foreach (BinaryData item in client.GetEnvironmentsAsync("<projectName>", "<userId>", null))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("parameters").GetProperty("<key>").ToString());
    Console.WriteLine(result.GetProperty("name").ToString());
    Console.WriteLine(result.GetProperty("environmentType").ToString());
    Console.WriteLine(result.GetProperty("user").ToString());
    Console.WriteLine(result.GetProperty("provisioningState").ToString());
    Console.WriteLine(result.GetProperty("resourceGroupId").ToString());
    Console.WriteLine(result.GetProperty("catalogName").ToString());
    Console.WriteLine(result.GetProperty("environmentDefinitionName").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
}

Applies to

GetEnvironmentsAsync(String, String, CancellationToken)

Source:
DeploymentEnvironmentsClient.cs

Lists the environments for a project and user.

public virtual Azure.AsyncPageable<Azure.Developer.DevCenter.Models.DevCenterEnvironment> GetEnvironmentsAsync (string projectName, string userId, System.Threading.CancellationToken cancellationToken = default);
abstract member GetEnvironmentsAsync : string * string * System.Threading.CancellationToken -> Azure.AsyncPageable<Azure.Developer.DevCenter.Models.DevCenterEnvironment>
override this.GetEnvironmentsAsync : string * string * System.Threading.CancellationToken -> Azure.AsyncPageable<Azure.Developer.DevCenter.Models.DevCenterEnvironment>
Public Overridable Function GetEnvironmentsAsync (projectName As String, userId As String, Optional cancellationToken As CancellationToken = Nothing) As AsyncPageable(Of DevCenterEnvironment)

Parameters

projectName
String

The DevCenter Project upon which to execute operations.

userId
String

The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

projectName or userId is null.

projectName or userId is an empty string, and was expected to be non-empty.

Examples

This sample shows how to call GetEnvironmentsAsync.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);

await foreach (DevCenterEnvironment item in client.GetEnvironmentsAsync("<projectName>", "<userId>"))
{
}

This sample shows how to call GetEnvironmentsAsync with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);

await foreach (DevCenterEnvironment item in client.GetEnvironmentsAsync("<projectName>", "<userId>"))
{
}

Applies to

GetEnvironmentsAsync(String, String, Nullable<Int32>, RequestContext)

Source:
DeploymentEnvironmentsClient.cs

[Protocol Method] Lists the environments for a project and user.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual Azure.AsyncPageable<BinaryData> GetEnvironmentsAsync (string projectName, string userId, int? maxCount, Azure.RequestContext context);
abstract member GetEnvironmentsAsync : string * string * Nullable<int> * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
override this.GetEnvironmentsAsync : string * string * Nullable<int> * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
Public Overridable Function GetEnvironmentsAsync (projectName As String, userId As String, maxCount As Nullable(Of Integer), context As RequestContext) As AsyncPageable(Of BinaryData)

Parameters

projectName
String

The DevCenter Project upon which to execute operations.

userId
String

The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.

maxCount
Nullable<Int32>

The maximum number of resources to return from the operation. Example: 'top=10'.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The AsyncPageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.

Exceptions

projectName or userId is null.

projectName or userId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call GetEnvironmentsAsync and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);

await foreach (BinaryData item in client.GetEnvironmentsAsync("<projectName>", "<userId>", null, null))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("environmentType").ToString());
    Console.WriteLine(result.GetProperty("catalogName").ToString());
    Console.WriteLine(result.GetProperty("environmentDefinitionName").ToString());
}

This sample shows how to call GetEnvironmentsAsync with all parameters and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);

await foreach (BinaryData item in client.GetEnvironmentsAsync("<projectName>", "<userId>", 1234, null))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("parameters").ToString());
    Console.WriteLine(result.GetProperty("name").ToString());
    Console.WriteLine(result.GetProperty("environmentType").ToString());
    Console.WriteLine(result.GetProperty("user").ToString());
    Console.WriteLine(result.GetProperty("provisioningState").ToString());
    Console.WriteLine(result.GetProperty("resourceGroupId").ToString());
    Console.WriteLine(result.GetProperty("catalogName").ToString());
    Console.WriteLine(result.GetProperty("environmentDefinitionName").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
}

Applies to