Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/devcenter/Azure.Developer.DevCenter/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ description: Samples for the Azure.Developer.DevCenter client library.

# Azure.Developer.DevCenter Samples

* [Create and delete a Dev Box](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/devcenter/Azure.Developer.DevCenter/samples/Sample_CreateDeleteDevBoxAsync.md)
* [Create and delete an Environment](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/devcenter/Azure.Developer.DevCenter/samples/Sample_CreateDeleteDevBoxAsync.md)
* [Create and delete a Dev Box](./Sample_CreateDeleteDevBoxAsync.md)
* [Create and delete an Environment](./Sample_CreateDeleteDevBoxAsync.md)

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ await foreach (BinaryData data in devCenterClient.GetProjectsAsync(filter: null,
Create a `DevBoxesClient` and issue a request to get all pools in a project.

```C# Snippet:Azure_DevCenter_GetPools_Scenario
var devBoxesClient = new DevBoxesClient(endpoint, targetProjectName, credential);
var devBoxesClient = new DevBoxesClient(endpoint, credential);
string targetPoolName = null;
await foreach (BinaryData data in devBoxesClient.GetPoolsAsync(filter: null, maxCount: 1))
await foreach (BinaryData data in devBoxesClient.GetPoolsAsync(targetProjectName, filter: null, maxCount: 1))
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
targetPoolName = result.GetProperty("name").ToString();
Expand All @@ -41,7 +41,7 @@ var content = new
poolName = targetPoolName,
};

Operation<BinaryData> devBoxCreateOperation = await devBoxesClient.CreateDevBoxAsync(WaitUntil.Completed, "MyDevBox", RequestContent.Create(content));
Operation<BinaryData> devBoxCreateOperation = await devBoxesClient.CreateDevBoxAsync(WaitUntil.Completed, targetProjectName, "MyDevBox", RequestContent.Create(content));
BinaryData devBoxData = await devBoxCreateOperation.WaitForCompletionAsync();
JsonElement devBox = JsonDocument.Parse(devBoxData.ToStream()).RootElement;
Console.WriteLine($"Completed provisioning for dev box with status {devBox.GetProperty("provisioningState")}.");
Expand All @@ -52,17 +52,17 @@ Console.WriteLine($"Completed provisioning for dev box with status {devBox.GetPr
Once your dev box is created, issue a request to get URLs for connecting to it via either web or desktop.

```C# Snippet:Azure_DevCenter_ConnectToDevBox_Scenario
Response remoteConnectionResponse = await devBoxesClient.GetRemoteConnectionAsync("MyDevBox");
Response remoteConnectionResponse = await devBoxesClient.GetRemoteConnectionAsync(targetProjectName, "MyDevBox");
JsonElement remoteConnectionData = JsonDocument.Parse(remoteConnectionResponse.ContentStream).RootElement;
Console.WriteLine($"Connect using web URL {remoteConnectionData.GetProperty("webUrl")}.");
```

## Create a dev box
## Delete a dev box

Issue a request to delete a dev box.

```C# Snippet:Azure_DevCenter_DeleteDevBox_Scenario
Operation devBoxDeleteOperation = await devBoxesClient.DeleteDevBoxAsync(WaitUntil.Completed, "MyDevBox");
Operation devBoxDeleteOperation = await devBoxesClient.DeleteDevBoxAsync(WaitUntil.Completed, targetProjectName, "MyDevBox");
await devBoxDeleteOperation.WaitForCompletionResponseAsync();
Console.WriteLine($"Completed dev box deletion.");
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ await foreach (BinaryData data in devCenterClient.GetProjectsAsync(filter: null,
}
```

## Get all catalog items in a project
## Get all environment definitions in a project

Create an `EnvironmentsClient` and issue a request to get all catalog items in a project.
Create an `EnvironmentsClient` and issue a request to get all environment definitions in a project.

```C# Snippet:Azure_DevCenter_GetCatalogItems_Scenario
var environmentsClient = new EnvironmentsClient(endpoint, projectName, credential);
string catalogItemName = null;
await foreach (BinaryData data in environmentsClient.GetCatalogItemsAsync(maxCount: 1))
var environmentsClient = new DeploymentEnvironmentsClient(endpoint, credential);
string environmentDefinitionName = null;
await foreach (BinaryData data in environmentsClient.GetEnvironmentDefinitionsAsync(targetProjectName, maxCount: 1))
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
catalogItemName = result.GetProperty("name").ToString();
environmentDefinitionName = result.GetProperty("name").ToString();
}
```

Expand All @@ -37,7 +37,7 @@ Issue a request to get all environment types in a project.

```C# Snippet:Azure_DevCenter_GetEnvironmentTypes_Scenario
string environmentTypeName = null;
await foreach (BinaryData data in environmentsClient.GetEnvironmentTypesAsync(maxCount: 1))
await foreach (BinaryData data in environmentsClient.GetEnvironmentTypesAsync(targetProjectName, maxCount: 1)
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
environmentTypeName = result.GetProperty("name").ToString();
Expand All @@ -46,17 +46,17 @@ await foreach (BinaryData data in environmentsClient.GetEnvironmentTypesAsync(ma

## Create an environment

Issue a request to create an environment using a specific catalog item and environment type.
Issue a request to create an environment using a specific definition item and environment type.

```C# Snippet:Azure_DevCenter_CreateEnvironment_Scenario
var content = new
{
environmentType = environmentTypeName,
catalogItemName = catalogItemName,
environmentDefinitionName = environmentDefinitionName,
};

// Deploy the environment
Operation<BinaryData> environmentCreateOperation = await environmentsClient.CreateOrUpdateEnvironmentAsync(WaitUntil.Completed, "DevEnvironment", RequestContent.Create(content));
Operation<BinaryData> environmentCreateOperation = await environmentsClient.CreateOrUpdateEnvironmentAsync(WaitUntil.Completed, targetProjectName, "DevEnvironment", RequestContent.Create(content));
BinaryData environmentData = await environmentCreateOperation.WaitForCompletionAsync();
JsonElement environment = JsonDocument.Parse(environmentData.ToStream()).RootElement;
Console.WriteLine($"Completed provisioning for environment with status {environment.GetProperty("provisioningState")}.");
Expand All @@ -67,7 +67,7 @@ Console.WriteLine($"Completed provisioning for environment with status {environm
Issue a request to delete an environment.

```C# Snippet:Azure_DevCenter_DeleteEnvironment_Scenario
Operation environmentDeleteOperation = await environmentsClient.DeleteEnvironmentAsync(WaitUntil.Completed, projectName, "DevEnvironment");
Operation environmentDeleteOperation = await environmentsClient.DeleteEnvironmentAsync(WaitUntil.Completed, targetProjectName, "DevEnvironment");
await environmentDeleteOperation.WaitForCompletionResponseAsync();
Console.WriteLine($"Completed environment deletion.");
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
</ItemGroup>

<ItemGroup>
<Folder Include="SessionRecords\EnvironmentCreateTests\" />
<Folder Include="SessionRecords\DevBoxCreateTests\" />
<Folder Include="SessionRecords\DevCenterClientTests\" />
</ItemGroup>

</Project>
Loading