azure-functions-devsec – skill DevOps & Hạ tầng cho agent AI
Xây dựng ứng dụng serverless trên Azure Functions. Cấu hình trigger, binding và triển khai. Dùng khi triển khai khối lượng công việc serverless trên Azure.
Cài skill azure-functions-devsec bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-functions-devsec-850f2.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /azure-functions-devsec – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-functions-devsec-850f2.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $azure-functions-devsec – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-functions-devsec-850f2.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /azure-functions-devsec – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-functions-devsec-850f2.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /azure-functions-devsec – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Azure Functions
Build and deploy serverless applications with Azure Functions. Covers function app creation, trigger and binding configuration, deployment strategies, real code examples in Python and Node.js, and production best practices.
When to Use
- You need event-driven compute that scales automatically to zero.
- You are building APIs, webhooks, or background processing pipelines.
- You want per-execution billing without managing servers.
- You need to respond to Azure service events (Blob Storage, Service Bus, Cosmos DB changes).
- You are implementing lightweight microservices or scheduled tasks.
Historical snippets require current runtime/plan/region and extension compatibility verification; scale-to-zero, billing and slot support vary by plan. Confirm subscription/resource IDs, cost, secrets, storage and rollback before provisioning/deploying/swapping. Function keys are shared access secrets, not user/object-level authorization. HTTP records here are synthetic examples, not persisted users. Validate/allowlist request fields and never spread arbitrary input into protected output/state.
Prerequisites
# Install Azure CLI
# Prerequisite: organization-approved Azure CLI installed from a verified signed package.
az version
# Install Azure Functions Core Tools v4
npm install -g azure-functions-core-tools@4
# Verify installation
func --version
# Login
az login
az account set --subscription "my-subscription-id"
# Create supporting resources
az group create --name functions-rg --location eastus
az storage account create \
--name myfuncstorageacct \
--resource-group functions-rg \
--location eastus \
--sku Standard_LRSFunction App Creation
Consumption Plan (Pay-per-execution)
# Python function app on Consumption plan
az functionapp create \
--resource-group functions-rg \
--consumption-plan-location eastus \
--runtime python \
--runtime-version 3.11 \
--functions-version 4 \
--name myapp-func \
--storage-account myfuncstorageacct \
--os-type Linux
# Node.js function app
az functionapp create \
--resource-group functions-rg \
--consumption-plan-location eastus \
--runtime node \
--runtime-version 20 \
--functions-version 4 \
--name myapp-node-func \
--storage-account myfuncstorageacct \
--os-type LinuxPremium Plan (VNet integration, no cold start)
# Create Premium plan
az functionapp plan create \
--resource-group functions-rg \
--name myapp-premium-plan \
--location eastus \
--sku EP1 \
--is-linux true
# Create function app on Premium plan
az functionapp create \
--resource-group functions-rg \
--plan myapp-premium-plan \
--runtime python \
--runtime-version 3.11 \
--functions-version 4 \
--name myapp-premium-func \
--storage-account myfuncstorageacctTrigger and Binding Examples
HTTP Trigger -- Python
# function_app.py (v2 programming model)
import azure.functions as func
import json
import logging
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
@app.route(route="users/{userId}", methods=["GET"])
def get_user(req: func.HttpRequest) -> func.HttpResponse:
user_id = req.route_params.get("userId")
logging.info(f"Fetching user: {user_id}")
if not user_id:
return func.HttpResponse(
json.dumps({"error": "userId is required"}),
status_code=400,
mimetype="application/json"
)
user = {"id": user_id, "name": "Jane Doe", "email": "[email protected]"}
return func.HttpResponse(
json.dumps(user),
status_code=200,
mimetype="application/json"
)
@app.route(route="users", methods=["POST"])
def create_user(req: func.HttpRequest) -> func.HttpResponse:
try:
body = req.get_json()
except ValueError:
return func.HttpResponse(
json.dumps({"error": "Invalid JSON"}),
status_code=400,
mimetype="application/json"
)
logging.info(f"Creating user: {body.get('name')}")
return func.HttpResponse(
json.dumps({"id": "new-id", "name": body.get("name")}),
status_code=201,
mimetype="application/json"
)HTTP Trigger -- Node.js
// src/functions/httpTrigger.js (v4 programming model)
const { app } = require("@azure/functions");
app.http("getUser", {
methods: ["GET"],
authLevel: "function",
route: "users/{userId}",
handler: async (request, context) => {
const userId = request.params.userId;
context.log(`Fetching user: ${userId}`);
if (!userId) {
return { status: 400, jsonBody: { error: "userId is required" } };
}
const user = { id: userId, name: "Jane Doe", email: "[email protected]" };
return { status: 200, jsonBody: user };
},
});
app.http("createUser", {
methods: ["POST"],
authLevel: "function",
route: "users",
handler: async (request, context) => {
const body = await request.json();
context.log(`Creating user: ${body.name}`);
return { status: 201, jsonBody: { id: "new-id", name: body.name } };
},
});Blob Trigger -- Python
@app.blob_trigger(arg_name="blob", path="uploads/{name}",
connection="AzureWebJobsStorage")
def process_upload(blob: func.InputStream):
logging.info(f"Processing blob: {blob.name}, Size: {blob.length} bytes")
content = blob.read()
# Process file content hereTimer Trigger -- Python
@app.timer_trigger(schedule="0 */5 * * * *", arg_name="timer",
run_on_startup=False)
def cleanup_job(timer: func.TimerRequest):
if timer.past_due:
logging.warning("Timer is past due")
logging.info("Running scheduled cleanup")
# Cleanup logic hereService Bus Trigger -- Python
@app.service_bus_queue_trigger(arg_name="msg", queue_name="orders",
connection="ServiceBusConnection")
@app.cosmos_db_output(arg_name="doc", database_name="mydb",
container_name="processed-orders",
connection="CosmosDBConnection")
def process_order(msg: func.ServiceBusMessage, doc: func.Out[func.Document]):
order = json.loads(msg.get_body().decode("utf-8"))
logging.info(f"Processing order: {order['id']}")
processed = {
"id": order["id"],
"status": "processed",
"items": order["items"],
"total": sum(item["price"] for item in order["items"])
}
doc.set(func.Document.from_dict(processed))Cosmos DB Change Feed Trigger -- Python
@app.cosmos_db_trigger_v3(arg_name="documents", database_name="mydb",
container_name="orders",
connection="CosmosDBConnection",
lease_container_name="leases",
create_lease_container_if_not_exists=True)
def on_order_change(documents: func.DocumentList):
for doc in documents:
logging.info(f"Document changed: {doc['id']}")Local Development
# Initialize a new Python function project
func init MyFunctionProject --python
cd MyFunctionProject
# Create a new function from template
func new --name HttpExample --template "HTTP trigger" --authlevel function
# Run locally
func start
# Run locally with specific port
func start --port 7072
# Test locally
curl http://localhost:7071/api/HttpExample?name=WorldDeployment
# Deploy using Core Tools
func azure functionapp publish myapp-func
# Deploy with build step for Python
func azure functionapp publish myapp-func --build remote
# Deploy using ZIP package
zip -r function.zip . -x ".git/*" ".venv/*" "__pycache__/*" "local.settings.json" ".env" ".env.*"
# Inspect the complete archive allowlist before upload; exclusion patterns alone
# cannot establish that keys, private files or old archives are absent.
az functionapp deployment source config-zip \
--resource-group functions-rg \
--name myapp-func \
--src function.zip
# Deploy via CI/CD with GitHub Actions
az functionapp deployment github-actions add \
--resource-group functions-rg \
--name myapp-func \
--repo "myorg/myrepo" \
--branch main \
--runtime python \
--login-with-githubDeployment Slots
# Create a staging slot
az functionapp deployment slot create \
--resource-group functions-rg \
--name myapp-func \
--slot staging
# Deploy to staging slot
func azure functionapp publish myapp-func --slot staging
# Test staging slot
curl https://myapp-func-staging.azurewebsites.net/api/health
# Swap staging to production
az functionapp deployment slot swap \
--resource-group functions-rg \
--name myapp-func \
--slot staging \
--target-slot production
# Roll back by swapping again
az functionapp deployment slot swap \
--resource-group functions-rg \
--name myapp-func \
--slot staging \
--target-slot productionApplication Settings and Security
… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- azure-identity-dotnet – SDK Azure Identity cho .NET. Thư viện xác thực cho client Azure SDK sử dụng Microsoft…
- azure-identity-java – Xác thực ứng dụng Java với dịch vụ Azure bằng Microsoft Entra ID (Azure AD).
- azure-identity-py – SDK Azure Identity cho xác thực Python. Dùng cho DefaultAzureCredential, managed…
- hermes-s6-container-supervision – Chỉnh sửa hoặc gỡ lỗi các dịch vụ s6 trong Docker image của Hermes.
- azure-identity-ts – Xác thực với dịch vụ Azure bằng nhiều loại thông tin xác thực.
- azure-keyvault – Quản lý secret và chứng chỉ trong Azure Key Vault. Cấu hình access policy, tích hợp với…
- azure-keyvault-keys-ts – Quản lý khóa mật mã bằng SDK Azure Key Vault Keys cho JavaScript (@azure/keyvault-keys)…
- azure-keyvault-py – SDK Azure Key Vault cho Python. Dùng để quản lý secret, khóa và chứng chỉ với lưu trữ an…