Partager via


DevBoxesClient.CreateDevBoxAsync Method

Definition

Overloads

CreateDevBoxAsync(WaitUntil, String, String, DevBox, CancellationToken)

Creates or replaces a Dev Box.

CreateDevBoxAsync(WaitUntil, String, String, String, RequestContent, RequestContext)

[Protocol Method] Creates or replaces a Dev Box.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.

CreateDevBoxAsync(WaitUntil, String, String, DevBox, CancellationToken)

Source:
DevBoxesClient.cs

Creates or replaces a Dev Box.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.Developer.DevCenter.Models.DevBox>> CreateDevBoxAsync (Azure.WaitUntil waitUntil, string projectName, string userId, Azure.Developer.DevCenter.Models.DevBox devBox, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateDevBoxAsync : Azure.WaitUntil * string * string * Azure.Developer.DevCenter.Models.DevBox * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.Developer.DevCenter.Models.DevBox>>
override this.CreateDevBoxAsync : Azure.WaitUntil * string * string * Azure.Developer.DevCenter.Models.DevBox * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.Developer.DevCenter.Models.DevBox>>
Public Overridable Function CreateDevBoxAsync (waitUntil As WaitUntil, projectName As String, userId As String, devBox As DevBox, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of DevBox))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

projectName
String

The DevCenter Project upon which to execute the operation.

userId
String

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

devBox
DevBox

Represents the body request of a Dev Box creation. Dev Box Pool name is required. Optionally set the owner of the Dev Box as local administrator.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

projectName, userId or devBox is null.

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

Applies to

CreateDevBoxAsync(WaitUntil, String, String, String, RequestContent, RequestContext)

Source:
DevBoxesClient.cs
Source:
DevBoxesClient.cs

[Protocol Method] Creates or replaces a Dev Box.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual System.Threading.Tasks.Task<Azure.Operation<BinaryData>> CreateDevBoxAsync (Azure.WaitUntil waitUntil, string projectName, string userId, string devBoxName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateDevBoxAsync : Azure.WaitUntil * string * string * string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
override this.CreateDevBoxAsync : Azure.WaitUntil * string * string * string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
Public Overridable Function CreateDevBoxAsync (waitUntil As WaitUntil, projectName As String, userId As String, devBoxName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Operation(Of BinaryData))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

projectName
String

The DevCenter Project upon which to execute the operation.

userId
String

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

devBoxName
String

The name of a Dev Box.

content
RequestContent

The content to send as the body of the request.

context
RequestContext

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

Returns

The Operation representing an asynchronous operation on the service.

Exceptions

projectName, userId, devBoxName or content is null.

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

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

using RequestContent content = RequestContent.Create(new
{
    poolName = "<poolName>",
});
Operation<BinaryData> operation = await client.CreateDevBoxAsync(WaitUntil.Completed, "<projectName>", "<userId>", "<devBoxName>", content);
BinaryData responseData = operation.Value;

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

This sample shows how to call CreateDevBoxAsync with all parameters and request content and parse the result.

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

using RequestContent content = RequestContent.Create(new
{
    poolName = "<poolName>",
    localAdministrator = "Enabled",
});
Operation<BinaryData> operation = await client.CreateDevBoxAsync(WaitUntil.Completed, "<projectName>", "<userId>", "<devBoxName>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).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());

Applies to