Cloud Deployment
2 TopicsDeploy your ASP.NET Core Web API with the help of GitHub Copilot for Azure in Visual Studio Code.
Introducing GitHub Copilot for Azure, your personal assistant to streamline the deployment process. It provides you with clear, step-by-step instructions to deploy your applications and assists with troubleshooting, making your development journey smoother and more efficient. In this blog, we’ll explore how to deploy an ASP.NET Core API to Azure using GitHub Copilot for Azure in Visual Studio Code. By leveraging Copilot’s AI capabilities, I’ll guide it with prompts to streamline the deployment process. Together, we’ll learn how to transform a locally developed API into a cloud-hosted solution with ease. Prerequisites An Azure account and a subscription. Create Azure for free or pay as you go A GitHub account and GitHub Copilot Subscription. creating-an-account-on-GitHub and quick start on copilots Visual Studio code. See more info on setting up vs code GitHub Copilot and GitHub Copilot Chat Extension. Set up GitHub Copilot in VS Code and Getting started with Copilot Chat in VS Code .NET SDK. Download it here, C# Dev-kit Extension in VS Code. More on C# Dev-kit Prepare I will be deploying the TodoApi developed with ASP.NET Core. The source code is available on GitHub. Follow these steps to have the project on your local machine. Head to the GitHub repo: Github-Copilot-for-Azure-TodoApi-Sample Clone the Repository on your terminal or download as Zip: git clone https://github.com/kemboi590/Github-Copilot-for-Azure-TodoApi-Sample-.git Change directory to the cloned folder: cd Github-Copilot-for-Azure-TodoApi-Sample- Install required Packages: dotnet restore Open with Visual Studio Code: code . Here is an illustration of the steps: Run the application - Open the inbuilt terminal on Visual Studio Code and type the following: dotnet run The API is now running and we can test it using REST Client. Calling REST APIs From the IDE Install the rest client extension. - Open the extension and search for Rest Client and install it. Open TodoApi.http file and start testing the routes: GitHub Copilot Set up When you install GitHub Copilot Extension, you also get GitHub Copilot Chat, a conversational extension that provides conversational AI assistance Go to extensions Search for GitHub Copilot Install GitHub Copilot for Azure GitHub Copilot for Azure extension is designed to help streamline the process of developing for Azure. On extensions, search for GitHub Copilot for Azure Install the extension Start your Conversation with GitHub Copilot for Azure extension Open the chat, use the shortcut keys: ctr + shift + I or open chat by clicking on the chat Icon. To use GitHub Copilot for Azure use azure then describe what you want it to help you with. I will share with you my prompts that I am using so that you can use them as well. Note: Your GitHub Copilot for Azure may not give the same output as mine. Here are the steps to Deploy our WebApp. Describe what you want GitHub Copilot for Azure to help you with. - Give a clear information so that the copilot will get to respond better. - Try this prompt: @Azure I have developed an ASP.NET Core web API using Visual Studio Code, which is a simple TodoAPI with CRUD Functionalities with no database, I would like to deploy it on azure with your help because I have no experience. Which services should I use and which options do I have to have it on azure - GitHub Copilot for Azure Suggest that for an API, we should use Azure App Services Let’s ask for more details @Azure to deploy Azure App services on Visual Studio Code, which are the available options? We now have three options, o Using Visual Studio Code Extension – App Service Extension o Manual Process – On Azure Portal o Automated CI/CD Pipeline on GitHub App Service Extension - I will go with the first Option (Using Visual Studio Code– App Service Extension) Asking for more steps I will ask GitHub Copilot to give me some steps I will use to deploy using App Service Extension @Azure Guide me on the steps using App Service Extension - Open the extensions and install App Service Extension - You will be requested to sign in to your azure account. Ensure you have azure subscription so that you can be able to deploy your API. Working with Azure tools - You will note that Azure icon is available is the side bar - Click on it and you will see the App Services under your subscription. Create an App Service Web App from the available options - Click on App Service and click on Create button (+) to create an App Service Web App. Web App Name - Give a unique name of your new web app and click Enter - I will name mine azure-copilot-demo Choose Runtime Stack - If you are following along with TodoApi project, select .NET 9 and click Enter. Select Pricing Tier Let’s ask copilot of these pricing tiers: @Azure While selecting the pricing tiers, i see three options. Free F1 Basic B1 Premium P1V2 Which one do I select I will select Basic (B1) because I consider my project small-to-medium applications and low-traffic production workloads. Web App created on the Terminal for Azure - It will take some few seconds for the web app to be created Publish your App - Want to know why should you publish your project? - Let’s ask GitHub copilot for Azure for clarification: @Azure what does this command do? - Open the terminal on the folder with the project and type the following command: dotnet publish -c Release -o ./bin/Publish New bin/publish Folder has been created - The folder contains our project which is now ready to deploy Deploy - Right Click on the new web app (azure-copilot-demo) on the list and choose deploy to web app - Browse the /bin/publish folder and select it: Deployment success - It will take some few mins for the Web App to be deployed. Check on your terminal for Azure. - Wait for some time then your web pp will be running on Azure. Working with deployed Web App - I will also use REST Client to test the deployed web App on Visual Studio Code. - The end pot I will be using will be: https://azure-copilot-demo.azurewebsites.net/ - Without starting the server this time, replace the Host Address with the one you got after deploying the web App. POST Request: - Test the other routes and they should all be working just fine. Conclusion We have been able to deploy our TodoApi with the help of GitHub Copilot for Azure. I hope you had a great time following a long and were able to deploy your application as well. You are not limited to deploying the Web Apps alone with the help of GitHub Copilot for Azure. Feel free to explore other services and remember to share feedback. Resources Get started with GitHub Copilot for Azure Preview Get started with GitHub Copilot Training Module on Microsoft Learn Example prompts for learning about Azure and your application with GitHub Copilot for Azure Preview169Views2likes0CommentsDeploying an Express.js API to Azure Using GitHub Copilot for Azure: A Step-by-Step Guide
In this step-by-step guide, we walk you through deploying an Express.js API written in TypeScript to Azure using GitHub Copilot for Azure. We start by setting up the project locally, configuring the Express.js API with TypeScript, and installing the necessary tools. Then, we guide you through installing and setting up the GitHub Copilot for Azure extension in Visual Studio Code, making it easier to provision and manage Azure resources. Finally, we show you how to deploy your application to Azure App Service, verify the deployment, and troubleshoot common issues. By the end of this guide, you'll have a fully deployed Express.js API on Azure, all with the help of AI-assisted tools that simplify cloud deployment and management.181Views2likes1Comment