arazzo: 1.0.1 info: title: Microsoft Azure Deploy Then Tear Down a Resource Group summary: Create a group, deploy a template, poll to success, then delete the whole group. description: >- An ephemeral environment lifecycle flow ideal for test or CI scenarios. The workflow creates a resource group, starts a template deployment, polls it to a terminal provisioning state, and then deletes the entire resource group to tear everything down. The teardown only runs when the deployment succeeded; a failed deployment ends the flow with the group left in place for inspection. Every step spells out its request inline so the flow can be read and executed without opening the underlying OpenAPI description. version: 1.0.0 sourceDescriptions: - name: azureResourceManager url: ../openapi/azure-resource-manager-openapi.yml type: openapi workflows: - workflowId: deploy-then-teardown summary: Stand up an ephemeral deployment then delete its resource group. description: >- Creates a resource group, deploys into it, polls to completion, and on success deletes the resource group. inputs: type: object required: - accessToken - subscriptionId - resourceGroupName - location - deploymentName - template properties: accessToken: type: string description: An Azure Resource Manager OAuth2 bearer access token. subscriptionId: type: string description: The ID of the target subscription. resourceGroupName: type: string description: The name of the ephemeral resource group. location: type: string description: The Azure region for the resource group (e.g. eastus). deploymentName: type: string description: The name of the deployment. template: type: object description: The inline ARM template content to deploy. parameters: type: object description: Name/value pairs that define the deployment parameters. apiVersion: type: string description: The Azure Resource Manager API version. default: '2024-03-01' steps: - stepId: createResourceGroup description: Create the ephemeral resource group that will host the deployment. operationId: ResourceGroups_CreateOrUpdate parameters: - name: Authorization in: header value: Bearer $inputs.accessToken - name: subscriptionId in: path value: $inputs.subscriptionId - name: resourceGroupName in: path value: $inputs.resourceGroupName - name: api-version in: query value: $inputs.apiVersion requestBody: contentType: application/json payload: location: $inputs.location successCriteria: - condition: $statusCode == 200 outputs: resourceGroupId: $response.body#/id - stepId: startDeployment description: Start an incremental template deployment into the ephemeral group. operationId: Deployments_CreateOrUpdate parameters: - name: Authorization in: header value: Bearer $inputs.accessToken - name: subscriptionId in: path value: $inputs.subscriptionId - name: resourceGroupName in: path value: $inputs.resourceGroupName - name: deploymentName in: path value: $inputs.deploymentName - name: api-version in: query value: $inputs.apiVersion requestBody: contentType: application/json payload: properties: template: $inputs.template parameters: $inputs.parameters mode: Incremental successCriteria: - condition: $statusCode == 201 outputs: deploymentId: $response.body#/id - stepId: pollDeployment description: >- Poll the deployment, branching to teardown on Succeeded and ending the flow (leaving the group in place) on Failed or Canceled. operationId: Deployments_Get parameters: - name: Authorization in: header value: Bearer $inputs.accessToken - name: subscriptionId in: path value: $inputs.subscriptionId - name: resourceGroupName in: path value: $inputs.resourceGroupName - name: deploymentName in: path value: $inputs.deploymentName - name: api-version in: query value: $inputs.apiVersion successCriteria: - condition: $statusCode == 200 outputs: provisioningState: $response.body#/properties/provisioningState onSuccess: - name: deploymentSucceeded type: goto stepId: deleteResourceGroup criteria: - context: $response.body condition: $.properties.provisioningState == "Succeeded" type: jsonpath - name: deploymentFailed type: end criteria: - context: $response.body condition: $.properties.provisioningState == "Failed" || $.properties.provisioningState == "Canceled" type: jsonpath - name: keepPolling type: goto stepId: pollDeployment criteria: - context: $response.body condition: $.properties.provisioningState != "Succeeded" && $.properties.provisioningState != "Failed" && $.properties.provisioningState != "Canceled" type: jsonpath - stepId: deleteResourceGroup description: Delete the entire resource group to tear down the ephemeral environment. operationId: ResourceGroups_Delete parameters: - name: Authorization in: header value: Bearer $inputs.accessToken - name: subscriptionId in: path value: $inputs.subscriptionId - name: resourceGroupName in: path value: $inputs.resourceGroupName - name: api-version in: query value: $inputs.apiVersion successCriteria: - condition: $statusCode == 202 outputs: resourceGroupId: $steps.createResourceGroup.outputs.resourceGroupId deploymentId: $steps.startDeployment.outputs.deploymentId finalProvisioningState: $steps.pollDeployment.outputs.provisioningState