Scripting Azure CLI with 6 Features in GitHub Copilot

GitHub Copilot is your AI programmer and I use it via an VS Code extension. I find this to be the most effective AI tool that I have come across so far. I have used this in scenarios when I am scripting with Azure PowerShell, Az CLI and Azure SDK for Python.

Here are my tips and positive experiences to share.

Code Generation

Prompting to creating azure resources such as a web app or sql server as stand alone is quite effective. As long as your prompts are clear, concise, specific prompts. You can see my video of a detailed experience of creating a sophisticated azure solution – https://www.youtube.com/watch?v=0lPKmDy7N2M&t=2s

Git Commit Message Generation

My most favourite feature is the git commit message generation based on the file changes. You click on the “AI” icon. It saves me some brain energy thinking of an appropriate comment rather than something mundane and generate like ‘updated’.

Code Fixing

When encountering errors, there are a few ways of getting GitHub copilot to help. One way is simply higlighting the error in the terminal and press CTRL + I

Code Comment Generation

A really neat feature is when you are about to write the next block of code or set of commands and you enter a code comment block such as # or // and Github Copilot will predict your next logical step when starting your comment with a few words to give it a hint. For example,

The grayed out words is what it is suggesting and then you complete the comment by hitting tab key.

Code generate based on comment line

Next, hit enter to the next new line below the comment and Github Copilot will suggest the az cli command aligned to the comment as such follows:

Code Explanations

Highlight some lines of code, hit CTRL+I to get copilot command bar and type /explain

In the left pane Copilot chat will respond:

I find this explanation to be thorough and helpful and easy to understand. Definitely a great resource for those starting out to learn Azure.

Final Thoughts

Using GitHub Copilot for creating and managing azure resources is definitely helpful and there are productivity gains. The code generation is most impactful for simple scenarios such as creating individual azure resources. When prompting for a solution such for a few different resource types and all connected through a VNet get challenging in a few prompts. You have to iteratively improve the code manually or re-prompt. Also you have to spot fix where Copilot doesn’t get it the way you want it to work. There are more features and capabilities, but these are features and experiences I use 80% of the time. You can explore all the functionality in detail at https://github.com/features/copilot/

Leave a Reply