Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6acd702
Generate with models
drielenr Nov 28, 2023
b4efee4
Updates after arch board meetting. Missing enum rename.
drielenr Jan 9, 2024
f8af7e6
regen after merge main
drielenr Mar 6, 2024
b23683c
regen after tsp updates
drielenr Mar 6, 2024
6302464
Add script for custom tsp update
drielenr Mar 20, 2024
9552214
Update tsp commit in main and regen
drielenr Mar 20, 2024
5b61ea2
Update tests to use model
drielenr Apr 9, 2024
17e29d3
Break down tests
drielenr Apr 10, 2024
20f411f
Add samples
drielenr Apr 16, 2024
bd8982a
Add snippets and update readme
drielenr Apr 17, 2024
382a0cb
clean up imports
drielenr Apr 17, 2024
4e592f9
Update changelog
drielenr Apr 17, 2024
979e428
Update version
drielenr Apr 17, 2024
6c008b2
Fix samples
drielenr Apr 17, 2024
fb8a711
Fix formatting
drielenr Apr 17, 2024
a94d79a
Regen after merge main
drielenr Apr 17, 2024
3236403
update latest tsp commit
drielenr Apr 17, 2024
71b3ed7
Push recordings to assets repo and update tag reference
drielenr Apr 17, 2024
bdcd2d4
Add words to be ignored by cspell
drielenr Apr 22, 2024
01a4b5f
Revert removal of skip_quote
drielenr Apr 23, 2024
d349f09
Re-record failing tests and fix create dev box test
drielenr Apr 23, 2024
72378c4
fix vcpus cspell file path
drielenr Apr 23, 2024
b734a7e
Regen latest main
drielenr Apr 25, 2024
d94631c
Revert removal of skip_quote
drielenr Apr 23, 2024
61df66d
Regen using latest tsp
drielenr Apr 25, 2024
32e55eb
temp fix api version
drielenr Apr 25, 2024
a721ec1
Fix readme section reference
drielenr Apr 25, 2024
d2de546
Revert "temp fix api version"
drielenr Apr 26, 2024
0189bc6
Regen latest main
drielenr Apr 26, 2024
e4be831
Rename to Operation Status
drielenr Apr 26, 2024
2370d53
Use the lro model in test assertion
drielenr Apr 26, 2024
1671155
Update changelong
drielenr Apr 30, 2024
29f7aa2
Update readme and code snippets
drielenr Apr 30, 2024
54ccd83
Rename samples
drielenr Apr 30, 2024
af0cf75
add async tests and update recordings
leti367 May 10, 2024
db4871f
add aync samples
leti367 May 12, 2024
00da9e5
fix issue in async samples
leti367 May 14, 2024
6d28510
Update tests recordings
leti367 May 15, 2024
52460ca
Update tests and re-record tests
leti367 May 15, 2024
8199391
patch waiting in playback mode
leti367 May 16, 2024
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
Prev Previous commit
Next Next commit
Update readme and code snippets
  • Loading branch information
drielenr authored and leti367 committed May 14, 2024
commit 29f7aa217c3c544984d7dd5785761c60ba8b6873
32 changes: 16 additions & 16 deletions sdk/devcenter/azure-developer-devcenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ python -m pip install azure-developer-devcenter

In order to interact with the Dev Center service, you will need to create an instance of a client. An **endpoint** and **credential** are necessary to instantiate the client object.

For the endpoint use the Dev Center URI. It should have the format `https://{tenantId}-{devCenterName}.{devCenterRegion}.devcenter.azure.com`. Set this value as the environment variable for `DEVCENTER_ENDPOINT`.
For the endpoint use the Dev Center URI. It should have the format `https://{tenantId}-{devCenterName}.{devCenterRegion}.devcenter.azure.com`.

For the credential use an [Azure Active Directory (AAD) token credential][authenticate_with_token], providing an instance of the desired credential type obtained from the [azure-identity][azure_identity_credentials] library.

Expand All @@ -52,7 +52,7 @@ from azure.developer.devcenter import DevCenterClient
from azure.identity import DefaultAzureCredential

# Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables:
# DEVCENTER_ENDPOINT, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# DEVCENTER_ENDPOINT, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
try:
endpoint = os.environ["DEVCENTER_ENDPOINT"]
except KeyError:
Expand All @@ -64,7 +64,7 @@ client = DevCenterClient(endpoint, credential=DefaultAzureCredential())

<!-- END SNIPPET -->

With `DevCenterClient` you can manipulate operations in [Dev Center, Dev Box and Environments REST operations group](https://learn.microsoft.com/rest/api/devcenter/developer/operation-groups).
With `DevCenterClient` you can execute operations in [Dev Center, Dev Box and Environments REST operations group](https://learn.microsoft.com/rest/api/devcenter/developer/operation-groups).

## Examples
* [Create, Connect and Delete a Dev Box](#create-connect-and-delete-a-dev-box)
Expand All @@ -81,7 +81,7 @@ from azure.developer.devcenter import DevCenterClient
from azure.identity import DefaultAzureCredential

# Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables:
# DEVCENTER_ENDPOINT, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# DEVCENTER_ENDPOINT, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
try:
endpoint = os.environ["DEVCENTER_ENDPOINT"]
except KeyError:
Expand Down Expand Up @@ -115,23 +115,23 @@ else:
raise ValueError("Missing Pool - please create one before running the example")

# Stand up a new Dev Box
print(f"\nStarting to create devbox in project {target_project_name} and pool {target_pool_name}")
print(f"\nStarting to create dev box in project {target_project_name} and pool {target_pool_name}")

create_response = client.begin_create_dev_box(
dev_box_poller = client.begin_create_dev_box(
target_project_name, "me", "Test_DevBox", {"poolName": target_pool_name}
)
devbox = create_response.result()
print(f"Provisioned dev box with status {devbox.provisioning_state}.")
dev_box = dev_box_poller.result()
print(f"Provisioned dev box with status {dev_box.provisioning_state}.")

# Connect to the provisioned Dev Box
remote_connection = client.get_remote_connection(target_project_name, "me", devbox.name)
remote_connection = client.get_remote_connection(target_project_name, "me", dev_box.name)
print(f"Connect to the dev box using web URL {remote_connection.web_url}")

# Tear down the Dev Box when finished
print(f"Starting to delete dev box.")

delete_response = client.begin_delete_dev_box(target_project_name, "me", "Test_DevBox")
delete_result = delete_response.result()
delete_poller = client.begin_delete_dev_box(target_project_name, "me", "Test_DevBox")
delete_result = delete_poller.result()
print(f"Completed deletion for the dev box with status {delete_result.status}")
```

Expand All @@ -148,7 +148,7 @@ from azure.developer.devcenter import DevCenterClient
from azure.identity import DefaultAzureCredential

# Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables:
# DEVCENTER_ENDPOINT, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# DEVCENTER_ENDPOINT, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
try:
endpoint = os.environ["DEVCENTER_ENDPOINT"]
except KeyError:
Expand Down Expand Up @@ -217,16 +217,16 @@ environment = {
"environmentDefinitionName": target_environment_definition_name,
}

create_response = client.begin_create_or_update_environment(
environment_poller = client.begin_create_or_update_environment(
target_project_name, "me", environment_name, environment
)
environment_result = create_response.result()
environment_result = environment_poller.result()
print(f"Provisioned environment with status {environment_result.provisioning_state}.")

# Tear down the environment when finished
print(f"Starting to delete environment.")
delete_response = client.begin_delete_environment(target_project_name, "me", environment_name)
delete_result = delete_response.result()
delete_poller = client.begin_delete_environment(target_project_name, "me", environment_name)
delete_result = delete_poller.result()
print(f"Completed deletion for the environment with status {delete_result.status}")
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create_dev_center_client():
from azure.identity import DefaultAzureCredential

# Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables:
# DEVCENTER_ENDPOINT, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# DEVCENTER_ENDPOINT, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
try:
endpoint = os.environ["DEVCENTER_ENDPOINT"]
except KeyError:
Expand All @@ -68,7 +68,7 @@ def dev_box_create_connect_delete():
from azure.identity import DefaultAzureCredential

# Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables:
# DEVCENTER_ENDPOINT, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# DEVCENTER_ENDPOINT, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
try:
endpoint = os.environ["DEVCENTER_ENDPOINT"]
except KeyError:
Expand Down Expand Up @@ -102,23 +102,23 @@ def dev_box_create_connect_delete():
raise ValueError("Missing Pool - please create one before running the example")

# Stand up a new Dev Box
print(f"\nStarting to create devbox in project {target_project_name} and pool {target_pool_name}")
print(f"\nStarting to create dev box in project {target_project_name} and pool {target_pool_name}")

create_response = client.begin_create_dev_box(
dev_box_poller = client.begin_create_dev_box(
target_project_name, "me", "Test_DevBox", {"poolName": target_pool_name}
)
devbox = create_response.result()
print(f"Provisioned dev box with status {devbox.provisioning_state}.")
dev_box = dev_box_poller.result()
print(f"Provisioned dev box with status {dev_box.provisioning_state}.")

# Connect to the provisioned Dev Box
remote_connection = client.get_remote_connection(target_project_name, "me", devbox.name)
remote_connection = client.get_remote_connection(target_project_name, "me", dev_box.name)
print(f"Connect to the dev box using web URL {remote_connection.web_url}")

# Tear down the Dev Box when finished
print(f"Starting to delete dev box.")

delete_response = client.begin_delete_dev_box(target_project_name, "me", "Test_DevBox")
delete_result = delete_response.result()
delete_poller = client.begin_delete_dev_box(target_project_name, "me", "Test_DevBox")
delete_result = delete_poller.result()
print(f"Completed deletion for the dev box with status {delete_result.status}")
# [END dev_box_create_connect_delete]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def environment_create_and_delete():
from azure.identity import DefaultAzureCredential

# Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables:
# DEVCENTER_ENDPOINT, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# DEVCENTER_ENDPOINT, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
try:
endpoint = os.environ["DEVCENTER_ENDPOINT"]
except KeyError:
Expand Down Expand Up @@ -118,16 +118,16 @@ def environment_create_and_delete():
"environmentDefinitionName": target_environment_definition_name,
}

create_response = client.begin_create_or_update_environment(
environment_poller = client.begin_create_or_update_environment(
target_project_name, "me", environment_name, environment
)
environment_result = create_response.result()
environment_result = environment_poller.result()
print(f"Provisioned environment with status {environment_result.provisioning_state}.")

# Tear down the environment when finished
print(f"Starting to delete environment.")
delete_response = client.begin_delete_environment(target_project_name, "me", environment_name)
delete_result = delete_response.result()
delete_poller = client.begin_delete_environment(target_project_name, "me", environment_name)
delete_result = delete_poller.result()
print(f"Completed deletion for the environment with status {delete_result.status}")
# [END environment_create_and_delete]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
and sample on how to create a dev box at create_devbox_sample.py in this folder

USAGE:
python devbox_action_sample.py
python dev_box_action_sample.py

Set the environment variables with your own values before running the sample:
1) DEVCENTER_ENDPOINT - the endpoint for your devcenter
Expand All @@ -50,7 +50,7 @@
def main():

# Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables:
# DEVCENTER_ENDPOINT, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# DEVCENTER_ENDPOINT, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
try:
endpoint = os.environ["DEVCENTER_ENDPOINT"]
except KeyError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from azure.identity import DefaultAzureCredential

"""
FILE: devbox_restart_sample.py
FILE: dev_box_restart_sample.py

DESCRIPTION:
This sample demonstrates how to restart, stop and start a dev box using python DevCenterClient.
Expand All @@ -49,7 +49,7 @@
def main():

# Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables:
# DEVCENTER_ENDPOINT, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# DEVCENTER_ENDPOINT, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
try:
endpoint = os.environ["DEVCENTER_ENDPOINT"]
except KeyError:
Expand Down Expand Up @@ -77,18 +77,18 @@ def main():

# Stop dev box if it's running
if target_dev_box.power_state == PowerState.Running:
stop_response = client.begin_stop_dev_box(project_name, user, dev_box_name)
stop_result = stop_response.result()
stop_poller = client.begin_stop_dev_box(project_name, user, dev_box_name)
stop_result = stop_poller.result()
print(f"Stopping dev box completed with status {stop_result.status}")

# At this point we should have a stopped dev box . Let's start it
start_response = client.begin_start_dev_box(project_name, user, dev_box_name)
start_result = start_response.result()
start_poller = client.begin_start_dev_box(project_name, user, dev_box_name)
start_result = start_poller.result()
print(f"Starting dev box completed with status {start_result.status}")

# Restart the dev box
restart_response = client.begin_restart_dev_box(project_name, user, dev_box_name)
restart_result = restart_response.result()
restart_poller = client.begin_restart_dev_box(project_name, user, dev_box_name)
restart_result = restart_poller.result()
print(f"Done restarting the dev box with status {start_result.status}")


Expand Down