Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare applications for Azure deployment by generating infrastructure code, Dockerfiles, and config files.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/functions/templates/recipes/common/health-check.md
1# Health Check Endpoint23> **RECOMMENDED**: Add a health endpoint for monitoring and load balancer probes.45## Python67```python8@app.route(route="health", methods=["GET"], auth_level=func.AuthLevel.ANONYMOUS)9def health(req: func.HttpRequest) -> func.HttpResponse:10return func.HttpResponse(11'{"status":"healthy"}',12mimetype="application/json",13status_code=20014)15```1617## TypeScript1819```typescript20import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions';2122app.http('health', {23methods: ['GET'],24authLevel: 'anonymous',25handler: async (request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> => {26return {27status: 200,28jsonBody: { status: 'healthy' }29};30}31});32```3334## JavaScript3536```javascript37const { app } = require('@azure/functions');3839app.http('health', {40methods: ['GET'],41authLevel: 'anonymous',42handler: async () => ({43status: 200,44jsonBody: { status: 'healthy' }45})46});47```4849## C# (.NET)5051```csharp52public class Health53{54[Function("health")]55public HttpResponseData Run(56[HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData req)57{58var response = req.CreateResponse();59response.Headers.Add("Content-Type", "application/json");60response.WriteString("{\"status\":\"healthy\"}");61return response;62}63}64```6566## Java6768```java69@FunctionName("health")70public HttpResponseMessage health(71@HttpTrigger(name = "req", methods = {HttpMethod.GET}, authLevel = AuthorizationLevel.ANONYMOUS)72HttpRequestMessage<Optional<String>> request,73final ExecutionContext context) {7475return request.createResponseBuilder(HttpStatus.OK)76.header("Content-Type", "application/json")77.body("{\"status\":\"healthy\"}")78.build();79}80```8182## PowerShell8384**health/function.json:**85```json86{87"bindings": [88{89"authLevel": "anonymous",90"type": "httpTrigger",91"direction": "in",92"name": "Request",93"methods": ["get"]94},95{96"type": "http",97"direction": "out",98"name": "Response"99}100]101}102```103104**health/run.ps1:**105```powershell106param($Request, $TriggerMetadata)107108Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{109StatusCode = [HttpStatusCode]::OK110Body = '{"status":"healthy"}'111ContentType = 'application/json'112})113```114115## Usage Notes116117- **Auth level**: Use `anonymous` for load balancer probes118- **Response**: Return JSON with at least `{"status":"healthy"}`119- **Extended checks**: Can add database connectivity, dependency checks120- **Route**: Standard route is `/api/health`121