Quickstart: Clean up¶
In this quickstart, you delete a project, a scale set or your whole AI Factory with one call each. A delete removes the Azure resource groups that ESAF created, and nothing else.
Tip
Run it guided. The ESAF Tutorial Guide types each command for you and checks every step: open an ESAF tutorial and the track Scenarios 4-6. Download the ESAF Tutorial Guide. It's a private preview: ask Joakim Åström on LinkedIn for a preview code.
The scenario video, 9 minutes. Watch it in the ESAF Tutorial Guide under Resources > Scenario videos.
| Scenario | What goes | What stays |
|---|---|---|
| 4. Delete project | The project's resource group, with its Key Vault | Other projects, the scale set, the project's subnets |
| 5. Delete scale set | The scale set's project and common resource groups in that environment | Other scale sets, other environments |
| 6. Delete AI Factory | Every project and common resource group, and the Factory's local configuration | Hub resource groups, subscriptions, Entra groups, Git history |
Prerequisites¶
- A Factory from Quickstart: Create your AI Factory.
- The Factory API running, and your tool connected. See Quickstart: Install the ESAF tools.
- No other job running on the Factory. A second scenario waits until the first one ends.
Delete what you no longer need¶
Caution
A delete is permanent, and running it is the approval. Check the project number and the environment before you press Enter. A delete never reaches another environment.
Run only the lines you need. To remove everything, the last line is enough. The first two lines delete project 002 and scale set 002 from the earlier quickstarts. The recorded project delete took about 30 minutes.
- In the app, open the menu and select Configuration wizard > Quick setup & tear down.
- Select 4. Delete project, 5. Delete scale set or 6. Delete AI Factory, and enter the target.
- In Deletion phrase, type the phrase that the page asks for. It names what you delete.
- Tick I approve this scenario: it runs at once and changes Azure., then select Run selected scenario.
- Follow Job status on the same page until it shows that the job succeeded.
from azurefactory import esaf
job = esaf.delete_project("002", "dev", wait=True)
print(job.scenario, job.result["status"])
job = esaf.delete_scale_set("002", "dev", wait=True)
print(job.scenario, job.result["status"])
job = esaf.delete_factory(wait=True)
print(job.scenario, job.result["status"])
wait=True waits until the job ends, so each delete starts after the one before it.
In Bash, with API_URL, API_KEY and FOLDER set as in
Quickstart: Create your AI Factory:
jq -n --arg folder "$FOLDER" '{folder: $folder, approved: true, project: "002", environment: "dev"}' |
curl --silent --show-error --fail-with-body -X POST "$API_URL/api/v1/esaf/delete-project" \
--header "X-API-Key: $API_KEY" --header 'Content-Type: application/json' --data @-
For a scale set, post scale_set and environment to /api/v1/esaf/delete-scale-set. For the whole
Factory, post only folder and approved to /api/v1/esaf/delete-factory:
Two options change what a project delete removes:
| Option | What it does |
|---|---|
include_project_subnets=True, or --include-project-subnets |
Also deletes the project's subnets. |
include_keyvault_and_resource_group=False, or --keep-keyvault-and-resource-group |
Deletes only the project's services and keeps its Key Vault and resource group. |
You don't grant a deletion permission first. The API grants it once for the Factory, then runs the delete.
Verify the result¶
Each job ends with status succeeded. After a Factory delete, the resource groups are gone:
Expected output: no resource group that starts with your Factory's prefix.
| Job status | What to do |
|---|---|
blocked |
Another job is still running on the Factory, or a review refused the delete. Read blockers in the job. |
| A scale-set call says the target is unknown | You skipped Quickstart: Add a scale set. Leave that line out. |
failed |
Read problem in the job, then run the same call again. Deletes that are already done are skipped. |
Clean up resources¶
A Factory delete keeps what other teams may share. Remove these yourself when you no longer need them:
- The hub resource groups, if you created a hub only for this Factory.
- The Microsoft Entra groups and the Agent Chat sign-in registration.
- Your consumer repository.
Then close the app. That stops the Factory API.
Next step¶
Back: Quickstart: Create your first agent by enabling ESAF Agent Chat
Next: Usage docs - project team
Related:
- Guide 20: Remove, observe and recover: review a delete before it runs, or recover a stopped job.
- The six scenarios: every call and its parameters.
