Compartir a través de


DeploymentEnvironmentsClient.GetEnvironment 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 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

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 GetEnvironment 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 = client.GetEnvironment("<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 GetEnvironment 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 = client.GetEnvironment("<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