-
Notifications
You must be signed in to change notification settings - Fork 0
Lab 00 Preparing your environment
In this lab you are going to prepare an environment for the workshop.
- You need an active GitHub account: if you don't have one, create one here.
- Make sure you have an Azure subscription and
Owneraccess to at least one resource group. If you don't have one, create one here. You will need a credit card. Make sure to delete all Azure resources once you're done, or it will be charged.
The labs are designed to be run using GitHub Codespaces. Codespaces incur cost for compute and storage. For this reason you need GitHub account with quota for Codespace usage. If you have a personal account you are able to use 60 core hours per month from the free plan. Alternatively, if your GitHub account is part of an organization, you need at least an active Team plan to be allowed to use Codespaces. Should your organizational GitHub account not include Codespace quota, you can create a new personal account and use the free plan.
You will use GitHub Codespaces to run a development machine from development containers hosted in the cloud by GitHub. The use of GitHub Codespaces requires only a modern browser and no setup on your laptop,
Go to https://github.com/loekd-consultancy/Workshop-Azure-AI to find the repository for the workshop.
On this page you should find a blue drop down with <> Code on it. Click it and select the Codespaces tab, followed by the button with three dots. See the red highlight in the picture below:
Click the first menu option + New with options.
On the next screen create a Codespace with the following configuration:
| Setting | Value |
|---|---|
| Branch | main |
| Dev container configuration | Azure-AI |
| Region | Pick one close to your location |
| Machine type | 4-core |
The new Codespace will have all the extensions and tooling you need pre-installed. It uses a DevContainer definition and additional scripting to set up the environment.
GitHub Codespaces is a cloud development environment that clones your repository into a container hosting a remote development server. By default, a browser connects to the server and opens a Visual Studio Code-like development environment. You can navigate around the repository by using the Explorer to browse files, Terminal for CLI commands, Run and Debug view to build/run, and the Ports view to see forwarded services.
This Codespace has been configured specifically for the workshop. It contains all the tools you will need to do the labs later.
If you are wondering how we did this, examine the devcontainer.json file from the solution root: .devcontainer/devcontainer.json.
It has features that are packaged scripts executed after the container was created. It has assigned named ports, so you can recognize them during debugging. Finally, it has added some extensions to editor to simplify development.
Get acquainted with your CodeSpace by building and running the solution we have prepared for you.
First, open the file src/AskVantage/Apis/ImageApi/Controllers/QuestionController.cs and click left of line number 28, to place a breakpoint in the code. It should appear as a red dot. This is the place where execution will halt, when we use this API to fetch persisted questions later.
In the menu on the left hand side, select Ctrl+Shift+D on Windows and Linux or Command+Shift+D on MacOS to select the Run and Debug menu. Select 'Debug AppHost' in the dropdown menu. Press the 'play' button to the left of the dropdown to start debugging.
On the bottom of your screen, there should be a tab named 'Ports'. During debugging, these ports will be mapped to apps running inside your Codespace environment.
Click on the 'globe' icon next to 'imageapi-http' to open the API in a new browser tab. It should indicate that the page cannot be found. This is expected behavior. In the address bar, append '/swagger' to the url to open the SwaggerUI user interface, that allows you to explore the API operations that are available.
Press the blue GET button to invoke the endpoint: /api/Question and click Try it out. Next, click Execute. If all goes well, Visual Studio Code should halt execution on line 28 of the API controller.
This implies that everything is working correctly. Stop the debugging session by clicking on the stop button of the debugger at the top of the screen.
The final things to know are for troubleshooting and cost saving purposes.
If you run into an issue with your Codespace, sometimes it helps to rebuild the container. Press Ctrl+Shift+P in Windows and Linux or Command+Shift+P on MacOS to open the command pallete. Type 'Codespaces: Rebuild Container' to rebuild. Your code changes won't be lost, so it's safe to do this.
Running a Codespace costs money. Once your monthly free credits have been used you will be charged. To minimize costs, shut down the Codespace if you are not using it. Your file changes will not be lost until the Codespace is actually deleted. Make sure to commit and push your code changes regularly.
That's it, you now have a basic understanding of GitHub Codespaces!