### Local Development Setup
Source: https://github.com/microsoft/azure-skills/blob/main/landing-page/README.md
Navigate to the landing-page directory, install dependencies, and start the local development server.
```bash
cd landing-page
npm ci
npm run dev
```
--------------------------------
### Install and Verify EF Core Tools
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-deploy/references/recipes/azd/ef-migrations.md
Install the EF Core tools globally and verify the installation by checking the version.
```bash
dotnet tool install --global dotnet-ef
dotnet ef --version # Verify installation
```
--------------------------------
### Quick Start with Autoconfigure
Source: https://github.com/microsoft/azure-skills/blob/main/skills/appinsights-instrumentation/references/sdk/azure-monitor-opentelemetry-exporter-java.md
This snippet indicates that autoconfigure is the preferred method for starting with OpenTelemetry. Use the `azure-monitor-opentelemetry-autoconfigure` artifact.
```java
// Prefer autoconfigure instead:
// azure-monitor-opentelemetry-autoconfigure
```
--------------------------------
### Install Azure Identity SDK
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-deploy/references/sdk/azure-identity-py.md
Install the azure-identity package using pip.
```bash
pip install azure-identity
```
--------------------------------
### Install Azure Document Intelligence .NET SDK
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-ai/references/sdk/azure-ai-document-intelligence-dotnet.md
Use the `dotnet add package` command to install the Azure.AI.DocumentIntelligence NuGet package.
```bash
dotnet add package Azure.AI.DocumentIntelligence
```
--------------------------------
### Install and Login to Azure CLI
Source: https://github.com/microsoft/azure-skills/blob/main/skills/entra-app-registration/references/cli-commands.md
Ensure Azure CLI is installed and log in to your Azure account. Optionally, set a default subscription.
```bash
az version
```
```bash
az login
```
```bash
az account set --subscription "Your Subscription Name"
```
--------------------------------
### Install Azure Developer CLI
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-deploy/references/sdk/azd-deployment.md
Use this command to install the Azure Developer CLI on your system.
```bash
curl -fsSL https://aka.ms/install-azd.sh | bash
```
--------------------------------
### Install Azure Identity Package
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-deploy/references/sdk/azure-identity-dotnet.md
Use the `dotnet add package` command to install the Azure.Identity NuGet package.
```bash
dotnet add package Azure.Identity
```
--------------------------------
### Build and Preview
Source: https://github.com/microsoft/azure-skills/blob/main/landing-page/README.md
Build the project for production and start a local server to preview the built output.
```bash
cd landing-page
npm run build
npm run preview
```
--------------------------------
### Verify Terraform Installation
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-validate/references/recipes/terraform/README.md
Check if Terraform is installed on the system. If not, refer to the official installation guide.
```bash
terraform version
```
--------------------------------
### Installing Context7 MCP
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/recipes/azd/terraform.md
Command to install the Context7 MCP if it's not available, which might be required for certain AVM Terraform module examples or guidance.
```bash
npx @upstash/context7-mcp@latest
```
--------------------------------
### Terraform VM Deployment Quickstart
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-compute/workflows/vm-creator/examples/terraform/README.md
Initialize, plan, and apply Terraform configurations to deploy a Linux VM. Ensure prerequisites like Terraform, Azure CLI login, and SSH keys are set up.
```bash
MY_IP=$(curl -s ifconfig.me)/32 # your current public IP, locked to /32
terraform init
terraform plan -var "vm_name=dev-vm" -var "admin_public_key=$(cat ~/.ssh/id_rsa.pub)" -var "subscription_id=$AZ_SUB" -var "resource_group_name=dev-vm-rg" -var "ssh_source_address_prefix=$MY_IP"
terraform apply -var "vm_name=dev-vm" -var "admin_public_key=$(cat ~/.ssh/id_rsa.pub)" -var "subscription_id=$AZ_SUB" -var "resource_group_name=dev-vm-rg" -var "ssh_source_address_prefix=$MY_IP"
```
--------------------------------
### Quick Setup for Foundry Resource
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/resource/create/references/patterns.md
This pattern completes the setup of a Foundry resource in a single operation. It handles resource group creation or selection and then deploys the resource. Use this for straightforward deployments.
```bash
# Ask user: "Use existing resource group or create new?"
# ==== If user chooses "Use existing" ====
# Count and list existing resource groups
TOTAL_RG_COUNT=$(az group list --query "length([])" -o tsv)
az group list --query "[-5:].{Name:name, Location:location}" --out table
# Based on count: show appropriate list and options
# User selects resource group
RG=""
# Fetch details to verify
az group show --name $RG --query "{Name:name, Location:location, State:properties.provisioningState}"
# Then skip to creating Foundry resource below
# ==== If user chooses "Create new" ====
# List regions and ask user to choose
az account list-locations --query "[].{Region:name}" --out table
# Variables
RG="rg-ai-services" # New resource group name
LOCATION="westus2" # User's chosen location
RESOURCE_NAME="my-foundry-resource"
# Create new resource group
az group create --name $RG --location $LOCATION
# Verify creation
az group show --name $RG --query "{Name:name, Location:location, State:properties.provisioningState}"
# Create Foundry resource in user's chosen location
az cognitiveservices account create \
--name $RESOURCE_NAME \
--resource-group $RG \
--kind AIServices \
--sku S0 \
--location $LOCATION \
--yes
# Get endpoint and keys
echo "Resource created successfully!"
az cognitiveservices account show \
--name $RESOURCE_NAME \
--resource-group $RG \
--query "{Endpoint:properties.endpoint, Location:location}"
az cognitiveservices account keys list \
--name $RESOURCE_NAME \
--resource-group $RG
```
--------------------------------
### Start Local Emulator
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/durable-task-scheduler/README.md
Use this command to start the Durable Task Scheduler emulator locally for development and testing. Ensure you have Docker installed and running.
```bash
# Start the emulator (see https://mcr.microsoft.com/v2/dts/dts-emulator/tags/list for available versions)
docker pull mcr.microsoft.com/dts/dts-emulator:latest
docker run -d -p 8080:8080 -p 8082:8082 --name dts-emulator mcr.microsoft.com/dts/dts-emulator:latest
# Dashboard available at http://localhost:8082
```
--------------------------------
### OnTokenIssuanceStart Function Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/entra-app-registration/references/sdk/microsoft-azure-webjobs-extensions-authentication-events-dotnet.md
This example demonstrates how to create an Azure Function that triggers on a token issuance start event, processes the request, and provides custom claims for the token.
```APIDOC
## OnTokenIssuanceStart
### Description
This function is triggered by a `WebJobsAuthenticationEventsTrigger` when a token issuance event starts. It processes the incoming `WebJobsTokenIssuanceStartRequest` and returns a `WebJobsTokenIssuanceStartResponse` that can include actions like providing custom claims.
### Method
`Run`
### Parameters
- `request` (WebJobsTokenIssuanceStartRequest) - The incoming request object containing details about the token issuance event.
- `log` (ILogger) - The logger instance for writing logs.
### Request Example
(Not directly shown, but the `request` parameter is of type `WebJobsTokenIssuanceStartRequest`)
### Response
#### Success Response
- `WebJobsAuthenticationEventResponse` - An object that contains a list of actions to be performed. In this example, it includes providing custom claims.
#### Response Example
```csharp
{
"Actions": [
{
"Claims": {
"claim": "value"
}
}
]
}
```
```
--------------------------------
### Agent Initialization and Sample Commands
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/references/azd-ai-cli.md
Commands for listing available AI agent samples and initializing a new project from a manifest URL or existing source code.
```bash
azd ai agent sample list # curated catalog -- pick a manifestUrl
azd ai agent init -m # scaffold from a sample
azd ai agent init --src # scaffold from existing source
```
--------------------------------
### Usage Example: Get Cached Data
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/app-service/templates/recipes/redis/source/python.md
This example demonstrates how to retrieve data from the cache using the `get_cache()` function. If the data is not found, it computes a value, stores it in the cache with a 5-minute TTL, and then returns it.
```python
from cache import get_cache
def get_cached(key: str):
cache = get_cache()
value = cache.get(key)
if value is None:
value = "computed-value"
cache.setex(key, 300, value) # TTL 5 minutes
return value
```
--------------------------------
### Initialize Hosted Agent
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/quick-start-hosted.md
Use this command to scaffold a new agent project. Ensure you replace placeholders like '' and '' with your specific values. The `--runtime` and `--entry-point` flags are critical for correct project setup.
```bash
azd ai agent init --no-prompt \
-m "" \
--deploy-mode code \
--runtime python_3_13 \
--entry-point main.py \
--agent-name
```
--------------------------------
### Bash Deployment Command Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-compute/workflows/vm-creator/references/delivery-options/save-local.md
Example of the bash command to deploy resources using Bicep templates. Ensure you are in the correct directory and have the necessary parameters defined.
```bash
cd ~/source/my-infra/infra/dev-vm
az deployment group create --resource-group dev-vm-rg --template-file main.bicep \
--parameters vmName=dev-vm adminUsername=azureuser \
adminPublicKey="$(cat ~/.ssh/id_rsa.pub)"
```
--------------------------------
### Minimal Durable Functions Orchestration Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/durable-task-scheduler/dotnet.md
This C# example demonstrates a minimal Durable Functions application. It includes an HTTP-triggered function to start an orchestration and a simple orchestration that calls an activity function.
```csharp
using Microsoft.Azure.Functions.Worker;
using Microsoft.DurableTask;
using Microsoft.DurableTask.Client;
public static class DurableFunctionsApp
{
[Function("HttpStart")]
public static async Task HttpStart(
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
[DurableClient] DurableTaskClient client)
{
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(nameof(MyOrchestration));
return await client.CreateCheckStatusResponseAsync(req, instanceId);
}
[Function(nameof(MyOrchestration))]
public static async Task MyOrchestration([OrchestrationTrigger] TaskOrchestrationContext context)
{
var result1 = await context.CallActivityAsync(nameof(SayHello), "Tokyo");
var result2 = await context.CallActivityAsync(nameof(SayHello), "Seattle");
return $"{result1}, {result2}";
}
[Function(nameof(SayHello))]
public static string SayHello([ActivityTrigger] string name) => $"Hello {name}!";
}
```
--------------------------------
### Start Azure AI Agent Locally
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/references/local-run.md
Run the Azure AI agent locally after activating the service directory's virtual environment. This command handles dependency installation and starts the agent server.
```bash
azd ai agent run
```
--------------------------------
### Provision Azure resources for the first time
Source: https://github.com/microsoft/azure-skills/blob/main/skills/python-appservice-deploy/references/deploy-azd.md
Create a new Azure environment and set the location and optional App Service SKU. This is a one-time setup before the initial deployment.
```bash
azd env new
azd env set AZURE_LOCATION
# Optional: override default SKU via the template's parameters
azd env set APP_SERVICE_SKU P0v3
```
--------------------------------
### Minimal Durable Functions App Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/durable-task-scheduler/java.md
A basic Java example demonstrating how to start an orchestration from an HTTP trigger, call an activity function, and return status information. Imports are crucial for Durable Functions.
```java
import com.microsoft.azure.functions.*;
import com.microsoft.azure.functions.annotation.*;
import com.microsoft.durabletask.*;
import com.microsoft.durabletask.azurefunctions.*;
public class DurableFunctionsApp {
@FunctionName("HttpStart")
public HttpResponseMessage httpStart(
@HttpTrigger(name = "req", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION)
HttpRequestMessage request,
@DurableClientInput(name = "durableContext") DurableClientContext durableContext) {
DurableTaskClient client = durableContext.getClient();
String instanceId = client.scheduleNewOrchestrationInstance("MyOrchestration");
return durableContext.createCheckStatusResponse(request, instanceId);
}
@FunctionName("MyOrchestration")
public String myOrchestration(
@DurableOrchestrationTrigger(name = "ctx") TaskOrchestrationContext ctx) {
String result1 = ctx.callActivity("SayHello", "Tokyo", String.class).await();
String result2 = ctx.callActivity("SayHello", "Seattle", String.class).await();
return result1 + ", " + result2;
}
@FunctionName("SayHello")
public String sayHello(@DurableActivityTrigger(name = "name") String name) {
return "Hello " + name + "!";
}
}
```
--------------------------------
### Upgrade Workflow Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-upgrade/references/languages/java/README.md
Illustrates the high-level workflow for upgrading legacy Azure SDKs, showing the sequence of precheck, plan, execute, and validate phases.
```text
"upgrade legacy azure sdk"
→ precheck
→ plan
→ execute
→ validate
```
--------------------------------
### HTTP Trigger Example for Azure Functions v4
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-cloud-migrate/references/services/functions/runtimes/javascript.md
An example of an HTTP trigger function using the v4 programming model. It handles GET and POST requests and retrieves a name from query parameters or the request body.
```javascript
app.http('httpFunction', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
const name = request.query.get('name') || (await request.text());
return { body: `Hello, ${name}!` };
}
});
```
--------------------------------
### HTTP Trigger
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-cloud-migrate/references/services/functions/runtimes/java.md
Example of an HTTP trigger for a Java Azure Function. It handles GET and POST requests and can access query parameters.
```APIDOC
## HTTP Trigger
### Description
Handles HTTP requests with GET and POST methods. Accesses query parameters to personalize the response.
### Method
GET, POST
### Endpoint
Dynamic based on function app configuration
### Parameters
#### Path Parameters
None
#### Query Parameters
- **name** (string) - Optional - The name to be greeted.
#### Request Body
Optional string payload for POST requests.
### Request Example
```json
{
"example": "POST request body or GET query parameter"
}
```
### Response
#### Success Response (200)
- **body** (string) - A greeting message.
#### Response Example
```json
{
"example": "Hello, [name]"
}
```
```
--------------------------------
### Example: Unknown Framework Detection Output
Source: https://github.com/microsoft/azure-skills/blob/main/skills/python-appservice-deploy/references/detect.md
This output is displayed when no supported framework is auto-detected, reminding the user to set a startup command manually.
```text
Detected: Python project, framework unknown.
The app will deploy, but App Service may not start it correctly until
you set a startup command:
az webapp config set -n -g --startup-file ''
See startup-commands.md for examples.
```
--------------------------------
### Durable Functions Setup - Requirements
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/durable-task-scheduler/python.md
Install the necessary Azure Functions and Durable Functions packages for Python. Finding the latest versions is recommended.
```txt
azure-functions
azure-functions-durable
azure-identity
```
--------------------------------
### Quick Start with Azure Developer CLI
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-deploy/references/sdk/azd-deployment.md
A common workflow for initializing, authenticating, and deploying an application using the Azure Developer CLI.
```bash
azd auth login
azd init
azd up # provision + build + deploy
```
--------------------------------
### Handle Token Issuance Start Event in .NET
Source: https://github.com/microsoft/azure-skills/blob/main/skills/entra-app-registration/references/sdk/microsoft-azure-webjobs-extensions-authentication-events-dotnet.md
This C# function demonstrates how to handle a token issuance start event using the Azure Functions Authentication Events SDK. It adds a custom claim to the token response. Ensure the Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents package is installed.
```csharp
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents;
using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart;
[FunctionName("OnTokenIssuanceStart")]
public static WebJobsAuthenticationEventResponse Run(
[WebJobsAuthenticationEventsTrigger] WebJobsTokenIssuanceStartRequest request,
ILogger log)
{
var response = new WebJobsTokenIssuanceStartResponse();
response.Actions.Add(new WebJobsProvideClaimsForToken
{
Claims = new Dictionary { { "claim", "value" } }
});
return response;
}
```
--------------------------------
### Initialize Project with Base Template
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/app-service/templates/recipes/README.md
Use this command to initialize a new project with a base template. Replace `` with the desired language and scenario.
```bash
# Pick template by language + scenario (see selection.md)
azd init -t -e "$ENV_NAME" --no-prompt
```
--------------------------------
### Common Deployment Patterns
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/models/deploy-model/preset/EXAMPLES.md
Illustrates typical workflows for deploying AI models, from quick deployments to full onboarding and error recovery.
```text
A: Quick Deploy Auth → Get Project → Check Region (✓) → Deploy
B: Region Select Auth → Get Project → Region (✗) → Query All → Select → Deploy
C: Full Onboarding Auth → No Projects → Create Project → Deploy
D: Error Recovery Deploy (✗) → Analyze → Fix → Retry
```
--------------------------------
### JavaScript - Upload Blob
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-storage/references/sdk-usage.md
This JavaScript example demonstrates uploading a blob to Azure Storage. Ensure you have `@azure/identity` and `@azure/storage-blob` installed. `DefaultAzureCredential` is used for authentication.
```javascript
import { DefaultAzureCredential } from "@azure/identity";
import { BlobServiceClient } from "@azure/storage-blob";
const client = new BlobServiceClient("https://ACCOUNT.blob.core.windows.net/", new DefaultAzureCredential());
const container = client.getContainerClient("my-container");
const blob = container.getBlockBlobClient("my-blob.txt");
await blob.uploadData(Buffer.from("Hello, Azure Storage!"));
```
--------------------------------
### Node.js Local Runtime Command
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/functional-verification.md
Command to install dependencies and start a Node.js application locally. Ensure the PORT environment variable is set if needed.
```bash
npm install && npm start
```
--------------------------------
### Set up Python Virtual Environment with UV
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/quick-start-hosted.md
Create and activate a Python virtual environment in the service source directory (`src//`). Install `uv` within this environment for faster dependency management. Ensure the venv is located correctly, as `azd ai agent run` resolves it relative to the service source.
```bash
cd src/
python -m venv .venv
# Activate the venv — pick the line for your shell:
.\.venv\Scripts\Activate.ps1 # Windows pwsh
source .venv/bin/activate # macOS / Linux
python -m pip install uv
cd - # back to project root for the azd commands below
```
--------------------------------
### FastAPI Startup Command Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/python-appservice-deploy/references/detect.md
For FastAPI projects, the startup command is always explicitly set using `uvicorn`. This ensures reliable startup, overriding any potential Flask auto-detection.
```bash
python -m uvicorn main:app --host 0.0.0.0
```
--------------------------------
### Real-time Transcription Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-ai/references/sdk/azure-ai-transcription-py.md
Start a real-time transcription stream for live audio input. Audio can be sent to the stream using methods like send_audio_file.
```python
stream = client.begin_stream_transcription(locale="en-US"); stream.send_audio_file("audio.wav")
```
--------------------------------
### API Query for Retail Prices
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-compute/workflows/vm-recommender/vm-recommender.md
This is an example of how to query the Azure Retail Prices API to get pricing information for VMs. It's essential for calculating estimated costs.
```text
priceType eq 'Reservation'
```
--------------------------------
### Create Project Directory
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/quick-start-hosted.md
Create a new directory for your project and navigate into it.
```bash
mkdir
cd
```
--------------------------------
### Node.js Dockerfile Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-cloud-migrate/references/services/app-service/code-migration.md
Use a Dockerfile for apps needing custom system dependencies or multi-process setups. Ensure the application binds to the port specified by the PORT environment variable.
```dockerfile
FROM node:20-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]
```
--------------------------------
### azd Initial Setup and Deployment Workflow
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/recipes/azd/terraform.md
Commands to initialize an azd environment, set variables, provision infrastructure using Terraform, and deploy services. 'azd up' combines provisioning and deployment.
```bash
# 1. Create azd environment
azd env new dev --no-prompt
# 2. Set required variables
azd env set AZURE_LOCATION eastus2
# 3. Provision infrastructure (runs terraform init, plan, apply)
azd provision
# 4. Deploy services
azd deploy
# Or do both with single command
azd up
```
--------------------------------
### Check Prerequisites with PowerShell
Source: https://github.com/microsoft/azure-skills/blob/main/skills/airunway-aks-setup/references/powershell-notes.md
Verifies if essential command-line tools like kubectl, make, and curl are installed on the system. Use this to ensure your environment is ready before proceeding with cluster setup.
```powershell
@('kubectl', 'make', 'curl') | ForEach-Object {
if (Get-Command $_ -ErrorAction SilentlyContinue) {
Write-Host "✓ $_ found"
} else {
Write-Host "✗ $_ NOT FOUND — install before continuing"
}
}
```
--------------------------------
### Example: FastAPI Detection Output
Source: https://github.com/microsoft/azure-skills/blob/main/skills/python-appservice-deploy/references/detect.md
This output confirms FastAPI detection and shows the explicit `uvicorn` startup command that will be set.
```text
Detected: FastAPI (Python 3.14)
Entry point: main.py → app
Setting startup command (always set for FastAPI):
python -m uvicorn main:app --host 0.0.0.0
```
--------------------------------
### Implement API to Get All Items from Cosmos DB
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/app-service/templates/recipes/cosmos/source/dotnet.md
Add an endpoint to retrieve all items from a specified Cosmos DB container. This example reads the database and container names from environment variables.
```csharp
app.MapGet("/api/items", async (CosmosClient cosmos) =>
{
var container = cosmos
.GetDatabase(Environment.GetEnvironmentVariable("COSMOS_DATABASE_NAME"))
.GetContainer(Environment.GetEnvironmentVariable("COSMOS_CONTAINER_NAME"));
var query = container.GetItemQueryIterator("SELECT * FROM c");
var results = new List();
while (query.HasMoreResults)
results.AddRange(await query.ReadNextAsync());
return Results.Ok(results);
});
```
--------------------------------
### Initialize Aspire Project and Set Environment
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/azure-context.md
Use this sequence for Aspire projects initialized with `azd init --from-code`. It ensures the subscription and location are set immediately after environment creation to prevent configuration drift.
```bash
azd init --from-code -e --no-prompt
azd env set AZURE_SUBSCRIPTION_ID
azd env set AZURE_LOCATION
azd env get-values
```
--------------------------------
### Gradle Build File After BOM Migration (Kotlin DSL)
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-upgrade/references/languages/java/bom-migration/bom-gradle.md
Example of a build.gradle.kts file after migrating to use the Azure SDK BOM. This setup centralizes Azure dependency versioning through the BOM.
```kotlin
dependencies {
implementation(enforcedPlatform("com.azure:azure-sdk-bom:{bom_version}"))
implementation("com.azure:azure-identity")
implementation("com.azure.resourcemanager:azure-resourcemanager")
}
```
--------------------------------
### Calling MCP Tool: Outlook Get Emails
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/references/foundry-tool-catalog.md
Example of calling an Outlook MCP tool to retrieve emails. The response content wraps the email data in a JSON object with a 'value' array.
```jsonc
POST {dp}/toolboxes/{tb}/mcp?api-version=v1
{
"jsonrpc": "2.0", "id": 2, "method": "tools/call",
"params": { "name": "outlook-1___outlook_GetEmailsV2",
"arguments": { "folderPath": "Inbox", "top": 3 } }
}
→ 200
{
"jsonrpc": "2.0", "id": 2,
"result": {
"content": [{ "type": "text",
"text": "{\n \"value\": [\n { \"Subject\": \"...\", \"From\": \"...\", ... }\n ]\n}" }],
"isError": false
}
}
```
--------------------------------
### Query Copilot SDK Documentation with Context7
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-hosted-copilot-sdk/references/copilot-sdk.md
Demonstrates how to use the Context7 MCP server to query Copilot SDK documentation. First, resolve the library ID, then query with a specific goal.
```bash
npx -y @upstash/context7-mcp@latest
```
--------------------------------
### Set Generic ASGI Startup Command (PowerShell)
Source: https://github.com/microsoft/azure-skills/blob/main/skills/python-appservice-deploy/references/startup-commands.md
Configure a startup command for a generic ASGI application using PowerShell. Replace `:` with your application's entry point. Ensure `uvicorn` is in `requirements.txt`.
```powershell
az webapp config set -n -g `
--startup-file "python -m uvicorn : --host 0.0.0.0 --port 8000"
```
--------------------------------
### Verify Guardrail Creation via CLI
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/references/guardrails/guardrail-api-create.md
After creating a guardrail, use this `az rest` GET command to verify its configuration by retrieving the policy details. Confirm that the `contentFilters` match your intended setup.
```bash
az rest --method GET \
--url "https://management.azure.com/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.CognitiveServices/accounts/${ACCOUNT_NAME}/raiPolicies/${POLICY_NAME}?api-version=2024-10-01"
```
--------------------------------
### Post-deploy message for unknown frameworks
Source: https://github.com/microsoft/azure-skills/blob/main/skills/python-appservice-deploy/references/post-deploy-message.md
Use this template when a framework like wsgi-generic, asgi-generic, or unknown is detected. It informs the user about the deployment, provides the app URL, explains the build and startup process, and guides on setting a startup command.
```bash
✅ Code deployed — but framework not detected.
🌐 App URL: https://.azurewebsites.net
It can take 2–3 minutes for App Service to finish building and start the
container. The site will likely return an error page until you set a
startup command (next step).
⚠️ We could not detect Flask, Django, or FastAPI in your project, so no
startup command was set automatically. Set one with:
az webapp config set -n -g \
--startup-file ""
Examples:
• Generic WSGI (gunicorn):
gunicorn --bind=0.0.0.0 --timeout 600 :
• Generic ASGI (uvicorn):
python -m uvicorn : --host 0.0.0.0 --port 8000
See references/startup-commands.md for more guidance.
📜 If you want to watch live logs:
az webapp log config -n -g --application-logging filesystem --level information
az webapp log tail -n -g
(The first command is a one-time prereq on a fresh app — without it the stream stays empty.)
```
--------------------------------
### Minimal Durable Functions Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/durable-task-scheduler/javascript.md
A basic Durable Functions setup including an activity, an orchestrator, and an HTTP starter function. The HTTP starter initiates the orchestration and returns status check URLs.
```javascript
const { app } = require("@azure/functions");
const df = require("durable-functions");
// Activity
df.app.activity("sayHello", {
handler: (city) => `Hello ${city}!`,
});
// Orchestrator
df.app.orchestration("myOrchestration", function* (context) {
const result1 = yield context.df.callActivity("sayHello", "Tokyo");
const result2 = yield context.df.callActivity("sayHello", "Seattle");
return `${result1}, ${result2}`;
});
// HTTP Starter
app.http("HttpStart", {
route: "orchestrators/{orchestrationName}",
methods: ["POST"],
authLevel: "function",
extraInputs: [df.input.durableClient()],
handler: async (request, context) => {
const client = df.getClient(context);
const instanceId = await client.startNew(request.params.orchestrationName);
return client.createCheckStatusResponse(request, instanceId);
},
});
```
--------------------------------
### Example azd Overlay Configuration
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/references/agent-metadata-contract.md
This snippet shows a sample configuration for an azd overlay, demonstrating how to define default environments and specific environment settings including evaluation suites.
```yaml
defaultEnvironment: dev
environments:
dev:
azd:
environmentName:
service:
evaluationSuites:
- id: smoke-core
suiteName:
suiteVersion: "1"
generationSource: eval-yaml
tags:
tier: smoke
purpose: baseline
suiteFile: .foundry/suites/-v1.json
dataset:
datasetVersion: "1"
datasetFile: .foundry/datasets/--v1.ref.json
datasetUri:
evaluators:
- name:
version: "1"
threshold: 4
definitionFile: .foundry/evaluators/-v1.json
```
--------------------------------
### Minimal Durable Functions Example - Python
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/durable-task-scheduler/python.md
A basic Durable Functions application in Python, including an HTTP starter, an orchestrator, and an activity function. This demonstrates the core components of a Durable Functions setup.
```python
import azure.functions as func
import azure.durable_functions as df
my_app = df.DFApp(http_auth_level=func.AuthLevel.FUNCTION)
# HTTP Starter
@my_app.route(route="orchestrators/{function_name}", methods=["POST"])
@my_app.durable_client_input(client_name="client")
async def http_start(req: func.HttpRequest, client):
function_name = req.route_params.get('function_name')
instance_id = await client.start_new(function_name)
return client.create_check_status_response(req, instance_id)
# Orchestrator
@my_app.orchestration_trigger(context_name="context")
def my_orchestration(context: df.DurableOrchestrationContext):
result1 = yield context.call_activity("say_hello", "Tokyo")
result2 = yield context.call_activity("say_hello", "Seattle")
return f"{result1}, {result2}"
# Activity
@my_app.activity_trigger(input_name="name")
def say_hello(name: str) -> str:
return f"Hello {name}!"
```
--------------------------------
### Complete app setup script
Source: https://github.com/microsoft/azure-skills/blob/main/skills/entra-app-registration/references/cli-commands.md
A bash script that automates the creation of an Azure AD app registration, adds Microsoft Graph permissions, grants admin consent, and creates a service principal. Outputs key identifiers like Application ID and Tenant ID.
```bash
#!/bin/bash
# Variables
APP_NAME="MyApplication"
REDIRECT_URI="http://localhost:3000"
echo "Creating app registration..."
APP_ID=$(az ad app create \
--display-name "$APP_NAME" \
--spa-redirect-uris "$REDIRECT_URI" \
--query "appId" -o tsv)
echo "App created with ID: $APP_ID"
echo "Adding Microsoft Graph permissions..."
GRAPH_RESOURCE_ID="00000003-0000-0000-c000-000000000000"
USER_READ_ID="e1fe6dd8-ba31-4d61-89e7-88639da4683d"
az ad app permission add --id $APP_ID \
--api $GRAPH_RESOURCE_ID \
--api-permissions "$USER_READ_ID=Scope"
echo "Granting admin consent..."
az ad app permission admin-consent --id $APP_ID
echo "Creating service principal..."
az ad sp create --id $APP_ID
TENANT_ID=$(az account show --query tenantId -o tsv)
echo ""
echo "App registration complete!"
echo "Application (Client) ID: $APP_ID"
echo "Tenant ID: $TENANT_ID"
echo "Redirect URI: $REDIRECT_URI"
```
--------------------------------
### Usage Example: Cache Data in Node.js
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/app-service/templates/recipes/redis/source/nodejs.md
Demonstrates how to use the `getRedisClient` function to retrieve a Redis client and perform cache operations like GET and SETEX. Ensure to call `getRedisClient()` before each Redis operation.
```javascript
const { getRedisClient } = require("./cache");
app.get("/api/cached", async (req, res) => {
const client = await getRedisClient();
let value = await client.get("my-key");
if (!value) {
value = "computed-value";
await client.setex("my-key", 300, value); // TTL 5 minutes
}
res.json({ value });
});
```
--------------------------------
### Multi-Mode Chaining: Capacity to Deploy
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/models/deploy-model/SKILL.md
Illustrates a common prompt pattern where Capacity Discovery is followed by a deployment mode (Preset or Customize). This pattern is used when users specify capacity requirements and deployment intent.
```text
Pattern: Capacity → Deploy
When a user specifies a capacity requirement AND wants deployment:
1. Run **Capacity Discovery** to find regions/projects with sufficient quota
2. Present findings to user
3. Ask: "Would you like to deploy with **quick defaults** or **customize settings**?"
4. Route to **Preset** or **Customize** based on answer
```
--------------------------------
### LLM Rephrasing Prompt Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/finetuning/workflows/dataset-creation.md
This prompt guides an LLM to generate diverse phrasings of an original request, maintaining key identifiers while varying tone and detail. It is useful for augmenting existing datasets for RFT.
```prompt
Generate N different phrasings of this request. Each should:
- Use different wording, tone, or level of detail
- Include the same key identifiers (order IDs, item names)
- Vary between formal, casual, frustrated, brief, and detailed styles
Return a JSON array of N strings.
Original: [your example]
```
--------------------------------
### Initialize Project with AZD
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/quick-start-hosted.md
Bootstrap the project directory with core Azure Developer CLI settings, including subscription and location, before initializing the AI agent.
```bash
azd init -t Azure-Samples/azd-ai-starter-basic . \
-e - \
--subscription \
-l \
--no-prompt
```
--------------------------------
### Durable Task Worker and Client Setup in JavaScript
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/services/durable-task-scheduler/javascript.md
This snippet demonstrates how to configure and run a Durable Task worker and client for applications outside of Azure Functions. It includes defining an orchestrator and an activity, building the worker, starting it, scheduling an orchestration, and waiting for its completion.
```javascript
const { createAzureManagedWorkerBuilder, createAzureManagedClient } = require("@microsoft/durabletask-js-azuremanaged");
const connectionString = "Endpoint=http://localhost:8080;Authentication=None;TaskHub=default";
// Activity
const sayHello = async (_ctx, name) => `Hello ${name} વિભાગ!`;
// Orchestrator
const myOrchestration = async function* (ctx, name) {
const result = yield ctx.callActivity(sayHello, name);
return result;
};
async function main() {
// Worker
const worker = createAzureManagedWorkerBuilder(connectionString)
.addOrchestrator(myOrchestration)
.addActivity(sayHello)
.build();
await worker.start();
// Client
const client = createAzureManagedClient(connectionString);
const instanceId = await client.scheduleNewOrchestration("myOrchestration", "World");
const state = await client.waitForOrchestrationCompletion(instanceId, true, 30);
console.log("Output:", state.serializedOutput);
await client.stop();
await worker.stop();
}
main().catch(console.error);
```
--------------------------------
### Install Azure OpenAI .NET SDK
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-ai/references/sdk/azure-ai-openai-dotnet.md
Use the dotnet CLI to add the Azure.AI.OpenAI package to your project.
```bash
dotnet add package Azure.AI.OpenAI
```
--------------------------------
### Bicep Parameter File Example
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-enterprise-infra-planner/references/bicep-generation.md
Define parameters for Bicep deployments, including location, environment name, and workload name. Ensure all parameters use @description() decorators.
```bicep
using './main.bicep'
param location = 'eastus'
param environmentName = 'prod'
param workloadName = 'datapipeline'
```
--------------------------------
### Install Azure AI SDKs
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/resource/private-network/references/end-to-end-test.md
Installs the necessary Python packages for interacting with Azure AI Projects. Ensure you have Python and pip installed.
```bash
pip install azure-ai-projects azure-identity azure-ai-agents
```
--------------------------------
### Install Azure AI Toolboxes Extension
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/references/tools.md
Install the `azure.ai.toolboxes` extension for the Azure Developer CLI. This is a one-time installation required to use toolbox functionalities.
```bash
azd extension install azure.ai.toolboxes
```
--------------------------------
### Initialize Azure Project and Agent (Recommended)
Source: https://github.com/microsoft/azure-skills/blob/main/skills/microsoft-foundry/foundry-agent/create/create-hosted.md
Use this method for scripted or agent-driven flows. It initializes the Azure project and agent, ensuring subscription and location are set before model resolution.
```bash
azd init -t Azure-Samples/azd-ai-starter-basic . -e --subscription -l
azd ai agent init -m --no-prompt --deploy-mode code --runtime python_3_13 --entry-point main.py
```
--------------------------------
### Install Azure Monitor OpenTelemetry Exporter
Source: https://github.com/microsoft/azure-skills/blob/main/skills/appinsights-instrumentation/references/sdk/azure-monitor-opentelemetry-exporter-py.md
Install the exporter package using pip. This command installs the necessary library for integrating with Azure Monitor.
```bash
pip install azure-monitor-opentelemetry-exporter
```
--------------------------------
### Initialize Project from Code with Environment
Source: https://github.com/microsoft/azure-skills/blob/main/skills/azure-prepare/references/recipes/azd/aspire.md
Use the `--from-code` flag when initializing a project from code to ensure all necessary configurations are detected. Specify the environment name using `-e`.
```bash
azd init --from-code -e "$ENV_NAME"
```