Passed CCAK Exam: Certificate of Cloud Auditing Knowledge Guide
December 30, 2024Microsoft Graph connectors @ Ignite 2024
December 31, 2024How I Used GitHub Copilot to Write a PowerShell GUI for Azure Tenant ID Lookup
When tasked with creating a PowerShell GUI to retrieve the Azure Tenant ID for any subscription, I decided to rely entirely on GitHub Copilot. Here’s how I did it—without manually writing a single line of code myself. (repo -> https://github.com/gsuttie/getTenantIdFromAzureSubscriptionId)
Setting Up
- Open Visual Studio Code: My preferred development environment. I enabled GitHub Copilot for code suggestions.
- Define Goals:
- A user-friendly GUI for inputting an Azure Subscription ID.
- Backend logic to retrieve the Tenant ID using Azure PowerShell.
- Automatically generate inline documentation and a comprehensive README file.
Prompting GitHub Copilot
- I started by creating a new PowerShell file and inputting the following prompt for Copilot:
Create a PowerShell script for a GUI that accepts an Azure Subscription ID, retrieves the Tenant ID using `Get-AzSubscription`, and displays it. Include inline comments and generate a README.
- I then tweeked the prompt a few times and the end result can be found in the following GitHub repo
Documentation and README
I added another comment to the script:
Generate a README file explaining the purpose of this script, its usage, prerequisites, and examples.
Copilot produced a structured README covering:
- Purpose: Explaining the script’s function.
- Usage: Step-by-step instructions on running the script.
- Prerequisites: Details about Azure PowerShell modules and authentication requirements.
- Example: A sample input and output demonstration.
Testing and Tweaking
I tested the script on a sample Azure environment. While functional, the GUI layout needed minor adjustments. I prompted Copilot with:
Improve the alignment and spacing of GUI elements.
This fine-tuned the interface, making it visually cleaner.
Final Output
With GitHub Copilot, I:
- Built a functional PowerShell GUI to retrieve Azure Tenant IDs.
- Included inline comments and documentation.
- Generated a detailed README without writing any code manually.
Summary
GitHub Copilot significantly accelerated the development process. While it handled 95% of the work, reviewing and testing were key to ensuring functionality and usability. This approach is ideal for tasks where speed and automation are priorities.
The post Get TenantId for any Azure Subscription appeared first on Azure Greg.