Partager via


DevBoxesClient.GetDevBoxAsync(String, String, String, RequestContext) Méthode

Définition

[Méthode de protocole] Obtient une dev Box

  • Cette méthode de protocole permet la création explicite de la demande et le traitement de la réponse pour les scénarios avancés.
public virtual System.Threading.Tasks.Task<Azure.Response> GetDevBoxAsync (string projectName, string userId, string devBoxName, Azure.RequestContext context);
abstract member GetDevBoxAsync : string * string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetDevBoxAsync : string * string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetDevBoxAsync (projectName As String, userId As String, devBoxName As String, context As RequestContext) As Task(Of Response)

Paramètres

projectName
String

Projet DevCenter sur lequel exécuter des opérations.

userId
String

ID d’objet AAD de l’utilisateur. Si la valeur est « moi », l’identité est extraite du contexte d’authentification.

devBoxName
String

Nom d’une Dev Box.

context
RequestContext

Contexte de la demande, qui peut remplacer les comportements par défaut du pipeline client par appel.

Retours

Réponse retournée par le service.

Exceptions

projectName, userId ou devBoxName a la valeur Null.

projectName, userId ou devBoxName est une chaîne vide, et était censé être non vide.

Le service a retourné un code de status non réussi.

Exemples

Cet exemple montre comment appeler GetDevBoxAsync et analyser le résultat.

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

Response response = await client.GetDevBoxAsync("<projectName>", "<userId>", "<devBoxName>", null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("poolName").ToString());

Cet exemple montre comment appeler GetDevBoxAsync avec tous les paramètres et analyser le résultat.

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

Response response = await client.GetDevBoxAsync("<projectName>", "<userId>", "<devBoxName>", null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("projectName").ToString());
Console.WriteLine(result.GetProperty("poolName").ToString());
Console.WriteLine(result.GetProperty("hibernateSupport").ToString());
Console.WriteLine(result.GetProperty("provisioningState").ToString());
Console.WriteLine(result.GetProperty("actionState").ToString());
Console.WriteLine(result.GetProperty("powerState").ToString());
Console.WriteLine(result.GetProperty("uniqueId").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());
Console.WriteLine(result.GetProperty("location").ToString());
Console.WriteLine(result.GetProperty("osType").ToString());
Console.WriteLine(result.GetProperty("user").ToString());
Console.WriteLine(result.GetProperty("hardwareProfile").GetProperty("skuName").ToString());
Console.WriteLine(result.GetProperty("hardwareProfile").GetProperty("vCPUs").ToString());
Console.WriteLine(result.GetProperty("hardwareProfile").GetProperty("memoryGB").ToString());
Console.WriteLine(result.GetProperty("storageProfile").GetProperty("osDisk").GetProperty("diskSizeGB").ToString());
Console.WriteLine(result.GetProperty("imageReference").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("imageReference").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("imageReference").GetProperty("operatingSystem").ToString());
Console.WriteLine(result.GetProperty("imageReference").GetProperty("osBuildNumber").ToString());
Console.WriteLine(result.GetProperty("imageReference").GetProperty("publishedDate").ToString());
Console.WriteLine(result.GetProperty("createdTime").ToString());
Console.WriteLine(result.GetProperty("localAdministrator").ToString());

S’applique à