Skip to main content

Azure Insights: Refactoring with Terraform; Deleting Resource Group resources; Running web apps with Arc

by MSCN Reporter
Staff Writer, MSDynamicsWorld.com

Microsoft Azure pros discuss refactoring with Terraform, deleting Resource Group resources, and running web apps with Azure Arc.

Setting up Terraform commands to refactor

Microsoft MVP Mike Stephenson recently faced a situation where he needed to refactor some Terraform solutions. In this case, the project involved a large Service Bus solution that he wanted to break into smaller components. Although it is comparatively easy to move resource definitions between different workspaces, problems arise when resources already exist.

To get around problems, Stephenson wrote a PowerShell script to read the state file and import commands for every resource in the file. He explained:

Once I had my file with all of the import commands I could parameterise then just with find/replace (Id probably make the script do this if I had more time). I then take the parameterised import commands and put them in a batch file in the workspace and then just make my devops pipeline run the commands the next time it runs and it will import all of the resources to the state for that environment.

As a final step, he removed commands from the batch file to clear the way for future pipeline runs.

Deleting all resources within a Resource Group

Chris Pietschmann, writing on Build5Nines, explained that there are sometimes situations where it makes sense to delete all of the resources in a particular Azure Resource Group. However, users may not want to delete the Resource Group itself. The az resource list and az resource delete commands, used together, can pull up a list of resources for deletion.

Pietschmann shared some Bash commands that work with Azure CLI to delete resources one-by-one. He added:

FREE Membership Required to View Full Content:

Joining MSDynamicsWorld.com gives you free, unlimited access to news, analysis, white papers, case studies, product brochures, and more. You can also receive periodic email newsletters with the latest relevant articles and content updates.
Learn more about us here

About MSCN Reporter
More about MSCN Reporter