Converting Bash scripts to PowerShell with GitHub CoPilot Chat
I recently downloaded a sample repository to deploy a Chroma and LangChain sample Open AI powered chatbot application to deploy an Azure. Create an Azure OpenAI, LangChain, ChromaDB, and Chainlit Chat App in Container Apps using Terraform - Microsoft Community Hub
It’s a cool deployment to have a play with OpenAI and to start interact with your own documents.
![Chainlit app in Azure](/images/uploadprocessed.jpg)
The solution is written to be deployed via Terraform, I won’t lie I was good at infrastructure as code back in 2017 (well maybe not good in the wow great code sense but things worked). After dusting off some terraform rustiness. I managed to deploy the infrastructure components.
- Resource Group
- Container Registry
- Container Apps Environment
- Chat Container
- Document Container
- OpenAI instance
- Managed Identity
- Log analytics
- ChromaDB - is deployed in the doc container
Going on to the deployment of the docker containers I noticed this were written in bash, I run Windows and yes, I know I can install the Linux subsystem and run the bash scripts but I know PowerShell and I have a new tool at my disposal. GitHub CoPilot Chat
To start the process all I had to do was highlight the bash scripts and right click CoPilot -> Start CoPilot Chat
![right click code and start copilot](/images/bashstartcopilot.jpg)
GitHub Copilot Chat automatically suggests the code and knows I need a new PowerShell file to go along with it. Accepting the change will create a new file. It’s important here that you don’t just accept the suggestion and run the file. I had to make a few minor changes.
![copilot chat created powershell script](/images/copilotpowershell.jpg)
My docker deployment scripts where now runnable and I hit a snag:
> [internal] load build definition from Dockerfile:
------
failed to solve with frontend dockerfile.v0: failed to read dockerfile: failed to create lease: write /var/lib/docker/buildkit/containerdmeta.db: read-only file system
Changing the the docker builtkit engine to true allowed me to resolve the issue
![Docker Engine builtkit=true](/images/dockerengine.jpg)
After an apply and restart I was able to build my docker images and deploy them to the container registry.
![PowerShell script building my docker images](/images/powershellrun.jpg)
The scripts weren’t the most advanced but it shows how useful a tool like GitHub CoPilot Chat could be migrating, modernizing and helping lazy people like me get out of a bind.
© 2024 - The Azure Shack - AI generated content throughout testing CoPilot Chat, OpenAI on Azure and Microsoft Designer