DeploymentEnvironmentsClient.GetEnvironmentAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetEnvironmentAsync(String, String, String, CancellationToken) |
Gets an environment. |
GetEnvironmentAsync(String, String, String, RequestContext) |
[Protocol Method] Gets an environment
|
GetEnvironmentAsync(String, String, String, CancellationToken)
Gets an environment.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Developer.DevCenter.Models.DevCenterEnvironment>> GetEnvironmentAsync (string projectName, string userId, string environmentName, System.Threading.CancellationToken cancellationToken = default);
abstract member GetEnvironmentAsync : string * string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Developer.DevCenter.Models.DevCenterEnvironment>>
override this.GetEnvironmentAsync : string * string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Developer.DevCenter.Models.DevCenterEnvironment>>
Public Overridable Function GetEnvironmentAsync (projectName As String, userId As String, environmentName As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of 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 GetEnvironmentAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);
Response<DevCenterEnvironment> response = await client.GetEnvironmentAsync("<projectName>", "<userId>", "<environmentName>");
This sample shows how to call GetEnvironmentAsync 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 = await client.GetEnvironmentAsync("<projectName>", "<userId>", "<environmentName>");
Applies to
GetEnvironmentAsync(String, String, String, RequestContext)
[Protocol Method] Gets an environment
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler GetEnvironmentAsync(String, String, String, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> GetEnvironmentAsync (string projectName, string userId, string environmentName, Azure.RequestContext context);
abstract member GetEnvironmentAsync : string * string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetEnvironmentAsync : string * string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetEnvironmentAsync (projectName As String, userId As String, environmentName As String, context As RequestContext) As Task(Of 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 GetEnvironmentAsync 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 = await client.GetEnvironmentAsync("<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 GetEnvironmentAsync 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 = await client.GetEnvironmentAsync("<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());