Share via


DevBoxesClient.CreateDevBox Method

Definition

Overloads

CreateDevBox(WaitUntil, String, String, DevBox, CancellationToken)

Creates or replaces a Dev Box.

CreateDevBox(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.

CreateDevBox(WaitUntil, String, String, DevBox, CancellationToken)

Source:
DevBoxesClient.cs

Creates or replaces a Dev Box.

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

CreateDevBox(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 Azure.Operation<BinaryData> CreateDevBox (Azure.WaitUntil waitUntil, string projectName, string userId, string devBoxName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateDevBox : Azure.WaitUntil * string * string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
override this.CreateDevBox : Azure.WaitUntil * string * string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
Public Overridable Function CreateDevBox (waitUntil As WaitUntil, projectName As String, userId As String, devBoxName As String, content As RequestContent, Optional context As RequestContext = Nothing) As 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 CreateDevBox 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 = client.CreateDevBox(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 CreateDevBox 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 = client.CreateDevBox(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