Compartir a través de


DeploymentEnvironmentsClient.GetEnvironmentAsync Método

Definición

[Método Protocol] Obtiene un entorno.

  • Este método de protocolo permite la creación explícita de la solicitud y el procesamiento de la respuesta para escenarios avanzados.
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)

Parámetros

projectName
String

Proyecto de DevCenter en el que se van a ejecutar las operaciones.

userId
String

Identificador de objeto de AAD del usuario. Si el valor es "me", la identidad se toma del contexto de autenticación.

environmentName
String

El nombre del entorno.

context
RequestContext

Contexto de solicitud, que puede invalidar los comportamientos predeterminados de la canalización de cliente por llamada.

Devoluciones

Respuesta devuelta por el servicio.

Excepciones

projectName, userId o environmentName es un valor null.

projectName, userId o environmentName es una cadena vacía y se esperaba que no estuviera vacía.

El servicio devolvió un código de estado no correcto.

Ejemplos

En este ejemplo se muestra cómo llamar a GetEnvironmentAsync y analizar el resultado.

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("environmentType").ToString());
Console.WriteLine(result.GetProperty("catalogName").ToString());
Console.WriteLine(result.GetProperty("environmentDefinitionName").ToString());

En este ejemplo se muestra cómo llamar a GetEnvironmentAsync con todos los parámetros y analizar el resultado.

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").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());

Se aplica a