Partager via


DeploymentEnvironmentsClient.GetEnvironment Method

Definition

Overloads

GetEnvironment(String, String, String, RequestContext)

[Protocol Method] Gets an environment

GetEnvironment(String, String, String, CancellationToken)

Gets an environment.

GetEnvironment(String, String, String, RequestContext)

Source:
DeploymentEnvironmentsClient.cs
Source:
DeploymentEnvironmentsClient.cs

[Protocol Method] Gets an environment

public virtual Azure.Response GetEnvironment (string projectName, string userId, string environmentName, Azure.RequestContext context);
abstract member GetEnvironment : string * string * string * Azure.RequestContext -> Azure.Response
override this.GetEnvironment : string * string * string * Azure.RequestContext -> Azure.Response
Public Overridable Function GetEnvironment (projectName As String, userId As String, environmentName As String, context As RequestContext) As Response

Parameters

projectName
String

Name of the project.

userId
String

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

environmentName
String

Environment name.

context
RequestContext

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

Returns

The response returned from the service.

Exceptions

projectName, userId or environmentName is null.

projectName, userId or environmentName 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 GetEnvironment and parse the result.

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

Response response = client.GetEnvironment("<projectName>", "<userId>", "<environmentName>", null);

JsonElement result = JsonDocument.Parse(response.ContentStream).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 GetEnvironment 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);

Response response = client.GetEnvironment("<projectName>", "<userId>", "<environmentName>", null);

JsonElement result = JsonDocument.Parse(response.ContentStream).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

GetEnvironment(String, String, String, CancellationToken)

Source:
DeploymentEnvironmentsClient.cs

Gets an environment.

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

Parameters

projectName
String

Name of the project.

userId
String

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

environmentName
String

Environment name.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

projectName, userId or environmentName is null.

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

Examples

This sample shows how to call GetEnvironment.

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

Response<DevCenterEnvironment> response = client.GetEnvironment("<projectName>", "<userId>", "<environmentName>");

This sample shows how to call GetEnvironment with all parameters.

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

Response<DevCenterEnvironment> response = client.GetEnvironment("<projectName>", "<userId>", "<environmentName>");

Applies to