serverless-architecture
Serverless architecture patterns with AWS Lambda, edge functions, and cold start optimization.
Works with
---
name: serverless-architecture
description: Serverless architecture patterns with AWS Lambda, edge functions, and cold start optimization.
license: Apache-2.0
---
# Serverless Architecture
Master serverless development with AWS Lambda, API Gateway, and event-driven patterns.
## Quick Reference
### AWS Lambda Function
```typescript
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'
export const handler = async (
event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResult> => {
try {
const body = JSON.parse(event.body || '{}')
// Business logic
const result = await processData(body)
return {
statusCode: 200,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
body: JSON.stringify(result)
}
} catch (error) {
return {
statusCode: 500,
body: JSON.stringify({ error: error.message })
}
}
}
```
### Serverless Framework
```yaml
# serverless.yml
service: my-service
provider:
name: aws
runtime: nodejs20.x
region: us-east-1
environment:
TABLE_NAME: ${self:service}-${self:provider.stage}
functions:
api:
handler: src/handler.handler
events:
- http:
path: /users
method: get
cors: true
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:provider.environment.TABLE_NAME}
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
BillingMode: PAY_PER_REQUEST
```
### Event-Driven Architecture
```typescript
// S3 event trigger
export const handler = async (event: S3Event) => {
for (const record of event.Records) {
const bucket = record.s3.bucket.name
const key = record.s3.object.key
// Process uploaded file
await processFile(bucket, key)
}
}
// SQS event trigger
export const handler = async (event: SQSEvent) => {
for (const record of event.Records) {
const message = JSON.parse(record.body)
await processMessage(message)
}
}
```
## Best Practices
- Keep functions small and focused
- Use environment variables for config
- Implement proper error handling
- Use layers for shared dependencies
- Set appropriate timeout and memory
- Monitor with CloudWatch
- Use provisioned concurrency for latency-sensitive functions
- Implement dead letter queues for failed eventsMore DevOps & Infrastructure skills
azure-ai
microsoft/azure-skills
Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.
appinsights-instrumentation
microsoft/azure-skills
Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. WHEN: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices.
azure-storage
microsoft/azure-skills
Azure Storage Services including Blob Storage, File Shares, Queue Storage, Table Storage, and Data Lake. Answers questions about storage access tiers (hot, cool, cold, archive), when to use each tier, and tier comparison. Provides object storage, SMB file shares, async messaging, NoSQL key-value, and big data analytics. Includes lifecycle management. USE FOR: blob storage, file shares, queue storage, table storage, data lake, upload files, download blobs, storage accounts, access tiers, storage tiers, hot cool cold archive, storage tier comparison, when to use storage tiers, lifecycle management, Azure Storage concepts. DO NOT USE FOR: SQL databases, Cosmos DB (use azure-prepare), messaging with Event Hubs or Service Bus (use azure-messaging).

