A concise collection of runnable .NET sample apps that demonstrate practical integration with GitHub Models and Azure AI Foundry. includes clear setup steps, environment configuration, and token/security guidance—ideal for learning, prototyping, and extending AI-enabled .NET applications.
- .NET 9 SDK or later
- Git installed
- GitHub account
- Access to AI models — one of:
- GitHub Models: a Personal Access Token with model access (https://github.com/settings/tokens)
- Azure AI Foundry: an Azure subscription and a Foundry project with a deployed model and service credentials (endpoint + key or managed identity)
- Star this repository ⭐ by clicking the "Star" button at the top of this page
- Fork this repository by clicking the "Fork" button at the top of this page
- This creates your own copy of the repository in your GitHub account
# Clone YOUR fork, not the original repository
git clone https://github.com/YOUR_USERNAME/GenAIStarter.git
cd GenAIStarter# Restore all project dependencies
dotnet restore GenAIStarter.sln
# Or build all projects (which also restores dependencies)
dotnet build-
Create your .env file:
cp .env.example .env
-
Add your API configuration to .env:
API_TOKEN=your_api_token_here API_ENDPOINT=https://models.github.ai/inference
You have two options for accessing models:
- GitHub-hosted models — use a personal access token with model access and point API_ENDPOINT to the GitHub inference URL; set API_TOKEN to the token.
- Azure Foundry — use your Foundry project’s endpoint and key (or managed identity); set API_ENDPOINT to the Foundry endpoint and API_TOKEN to the project key.
Example (.env)
API_ENDPOINT=https://models.github.ai/inference
API_TOKEN=your_api_token_here
Choose the provider that matches your account and credentials.
To use these demos, you need a GitHub personal access token with the models:read permission.
- Go to GitHub Settings > Developer settings > Personal access tokens
- Click "Generate new token" (classic or fine-grained)
- Give your token a name and select an expiration date
- Under "Select scopes", check
models:read - Click "Generate token" and copy the token (you won't be able to see it again)
Watch this short video for a step-by-step guide on generating your GitHub personal access token.
Keep your token secure and do not share it publicly.
-
Get an Azure subscription
- Students: sign up for Azure for Students (includes free $100 credit) — https://azure.microsoft.com/free/students/
- Not a student? Try the free trial ($200 credit) — https://azure.microsoft.com/free/
- Make sure your Microsoft account is associated with the subscription you will use for Foundry.
-
Sign in to Azure AI Studio
- Open https://ai.azure.com and sign in with the Microsoft account tied to your subscription.
- If you don’t yet have access to Foundry in your subscription, follow the on‑screen prompts to enable or request access.
-
Create a Foundry project
-
Deploy a model and open the Playground
- Inside your project, go to Model Catalog (or Models) and pick a model you want to use.
- Create a deployment (Deploy / Create endpoint). Select model version, compute size, and deployment name, then confirm.
- After deployment completes, open the Playground in the same project to test the model: select the deployed model from the model dropdown and run a prompt to validate behavior.

-
Retrieve credentials (Model + Endpoint)
-
In the project, open the deployed model’s details and find the “Model + endpoint” (or Endpoints) tab.
-
Copy the Endpoint URL and the API key/credential shown (some setups show a deployment-specific key or a “copy key” button).
-
Add these values to your .env or export them as environment variables:
API_ENDPOINT=https://<your-endpoint-url> API_TOKEN=<your_model_api_key>
-
Notes and tips
- Keep your API key secure; do not commit it to source control.
- Ensure the region and resource quota meet the model’s requirements before deploying.
- If you cannot see keys, check IAM/role permissions on the resource and that your account has access to the project and endpoint.
Each example can be run independently with its own command:
Simple question-answer interaction showing basic AI model usage.
dotnet run --project BasicExample.csprojBased on sample-basic.js
Interactive conversation with memory that maintains context across exchanges.
dotnet run --project MultiTurnChat.csprojBased on sample-multiturn.js
Specialized AI assistant for programming help, code examples, and debugging.
dotnet run --project CodingAssistant.csprojBased on assessment.js
Complex problem-solving scenarios including math, logic puzzles, and ethical dilemmas.
dotnet run --project ReasoningExample.csprojBased on sample-reasoning.js
AI-powered image analysis using GPT-4o's vision capabilities to describe and analyze images.
dotnet run --project ImageAnalysis.csprojBased on sample-image.js
Note: Place your images in the images/ directory. The example looks for sample.jpg by default.
Multi-turn travel assistance chatbot that helps with trip planning, bookings, and travel support.
dotnet run --project TravelingSupportAgent.csprojAssessment task for building a comprehensive travel support agent
Note: This is an assessment task - implement the traveling support agent according to the requirements in the file.
Complete the assessment as described below to earn your certificate and badge!
Once you have finished implementing your multi-turn coding assistant chatbot in TravelingSupportAgent.cs and submitted your pull request, you will be eligible to receive an official certificate and badge from MLSA.
How to claim your certificate and badge:
- Complete all steps in the "Assessment Task" section.
- Submit your pull request and create an issue as instructed.
- After your submission is reviewed and approved, you will receive your personalized certificate and badge via email.
- Follow the instructions below to commit your code, push your branch, and create a pull request for review.
-
Make a Pull Request
- Push your changes:
git add . git commit -m "Complete assessment" git push origin submission
- Create a pull request from your
submissionbranch to themainbranch on the Your repository.
Follow the above images for a visual guide on creating a pull request.
Tip: After creating your pull request, copy the PR link from your browser's address bar. You will need this link when creating your submission issue in the next step.
- Push your changes:
-
Create an Issue
- Go to the main repository and create an issue using the
submissiontemplate. - Fill in the following details:
- Full Name
- University
- Pull Request Link
- Review and Certification
- Once your submission is reviewed and approved, you will receive a badge and certificate.
- Replace
your_github_token_herein the.envfile with your actual GitHub token. - For the image input example, ensure the image file exists at the specified path.
- Independent examples: Each can be run separately
- Easy commands: Simple
dotnet runcommands - Educational: Each example teaches different AI concepts
- Interactive: Multi-turn conversations with context
- Clean output: Markdown formatting removed for better readability
- .NET 9.0
- API Token with appropriate access (e.g., GitHub Models token)
- Azure.AI.Inference package (already included)
Sample .NET console app that demonstrates two quick ways to call AI model endpoints via the Azure.AI.Inference SDK:
- Single turn: send a one-off prompt and print the reply.
- Multi turn: maintain the chat history and ask a follow-up question.
- Explore each example to understand different AI integration patterns
- Complete the traveling support agent assessment task
- Modify the examples to suit your specific use cases
- Add new examples for additional AI capabilities
- Experiment with different models and parameters
Follow me on social media for more sessions, tech tips, and giveaways:
- LinkedIn — Professional updates and networking
- Twitter (X) — Insights and announcements
- Instagram — Behind-the-scenes and daily tips
- GitHub — Repositories and project updates
- YouTube — Video tutorials and sessions
Feel free to connect and stay updated!
MIT









