flex-functions-sql-foundry
Skill5 starsChanged 46 days agoMITView on GitHub
Scaffold and deploy an Azure Functions Flex Consumption API with Azure SQL through managed identity and Microsoft Foundry. USE FOR: serverless APIs that need Flex Consumption, managed-identity Azure SQL access, Microsoft Foundry models, and deterministic azd/Bicep infrastructure. DO NOT USE FOR: Container Apps, AKS, SQL password authentication, non-HTTP workloads that need independent scaling, or projects that cannot use Azure CLI and azd.
- Reads credentials
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- journeys/smart-todo/setup/copilot-instructions.mdCopilot instructions
- container-apps-deploymentSkill
- data-access-abstractionSkill
- grafana-azureSkill
- grill-planSkill
- journey-runnerSkill
- journey-templateSkill
- journey-test-harnessSkill
- n8n-azureSkill
- superset-azureSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Use this skill for an Azure Functions Flex Consumption API that connects to Azure SQL through managed identity and calls a Microsoft …
- Distinctive: line 33
Do not deploy until the gate passes.
- Very specific: line 36
Run node scripts/check-infra.mjs before azd up.
- Very specific: line 65
Do not set FUNCTIONS_WORKER_RUNTIME.
- Very specific: line 67
Add the azd-service-name: api tag to the Function App.
- Distinctive: line 76
Use the SQL server resource's FQDN.
- Very specific: line 83
Create a raw Cognitive Services model deployment in a separate nested module after its account to avoid RequestConflict.
- Distinctive: line 94
Never print secrets, connection strings, app-setting values, developer IPs, or run-specific subscription, principal, or resource …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Flex Functions with SQL and Foundry
When to Use
Use this skill for an Azure Functions Flex Consumption API that connects to Azure SQL through managed identity and calls a Microsoft Foundry model.
Required Inputs
Collect these before generating infrastructure:
- Application name: 3-31 lowercase letters, numbers, and hyphens, starting with a letter
- Runtime language: an azd-supported value such as
ts,python,csharp, orjava - Azure region: verify SQL and model availability there
- Foundry model name and region-supported model version
Also resolve the deploying principal's ID, login, and type (User or
ServicePrincipal) before provisioning. Never guess missing identity values.
Fast Path and Gate
- Run
node scripts/scaffold-infra.mjs --target <directory> --name <app-name>. - Generate only application code or infrastructure changes the scaffold does not cover.
- Run
node scripts/check-infra.mjs --offline. - Do not deploy until the gate passes.
- Set the azd subscription, location, region-specific
AZURE_AI_MODEL_VERSION, principal ID, login, and type values. - Run
node scripts/check-infra.mjsbeforeazd up.
The scaffold and gate use only Node.js standard-library APIs and work from any
current directory. Do not copy .azure/, .env files, node_modules/, or
compiled Bicep JSON into a new project.
Resource Contract
- One azd service named
api, hosted on Azure Functions; device clients are not services. - Flex Consumption App Service plan with SKU
FC1. - Function App with system-assigned identity for runtime/deployment storage and a user-assigned identity used only for Azure SQL.
functionAppConfigwith a supported runtime, 2048 MB memory, maximum instance count, anddeploymentpackageblob storage authenticated by system identity.- Storage with shared-key access disabled, default network action
Allow, and adeploymentpackagecontainer. - Grant the Function App
Storage Blob Data Owner; grant the deployerStorage Blob Data Contributor; grant the Function App's system identityCognitive Services OpenAI Useron the Foundry account. - Azure SQL server with the deployer as Entra admin, an
AllowAzureServices0.0.0.0firewall rule, and a Basic 2 GB database with zone redundancy off. - A post-provision JavaScript hook creates the SQL identity user by client-ID SID, idempotently grants reader, writer, and DDL admin roles, attempts every cleanup action even after a cleanup failure, and never uses a SQL password.
- Microsoft Foundry/Azure OpenAI with local auth disabled (keyless) and the
selected model; use
GlobalStandardforgpt-5-mini. - Log Analytics and Application Insights.
- Function settings for SQL and AI providers, endpoints, deployment, SQL
FQDN/database/client ID (no AI key and no
listKeys()), and identity-basedAzureWebJobsStorage__accountName. Do not setFUNCTIONS_WORKER_RUNTIME; setsiteConfig.alwaysOntofalse. - Outputs use
SCREAMING_SNAKE_CASE;API_URLis the origin without/api. - Add the
azd-service-name: apitag to the Function App.
Known Deployment Gotchas
- SQL and model availability varies by region. Try
westus3,centralus, orsouthcentraluswhen needed, and query the region for the exact model version. - Basic Azure SQL rejects zone redundancy and limits
maxSizeBytesto 2 GB. - SQL's Entra admin principal type is
UserorApplication; map azdServicePrincipaltoApplication. Avoid reserved words such asWINDOWSin names. - Use the SQL server resource's FQDN. Appending the Azure suffix incorrectly can produce a double dot, while a short name causes DNS failures.
- For local SQL setup, temporarily add a developer-IP firewall rule. Switch a
Redirectconnection policy toProxyif outbound ports 11000-11999 are blocked, and restore the policy and delete the rule infinally. - Storage deployment failures usually mean the default action is not
Allow, the deployer lacks Blob Data Contributor, ordeploymentpackageis missing. - Create a raw Cognitive Services model deployment in a separate nested module
after its account to avoid
RequestConflict. - Flex Consumption rejects
alwaysOn: trueand a duplicateFUNCTIONS_WORKER_RUNTIMEsetting. - Oryx TypeScript builds need
src/andtsconfig.json; do not exclude them. - Invoke hooks through argument arrays. On Windows, use a static PowerShell
JSON-payload launcher so
.cmdAzure CLI shims work safely. - Simulator
Application failed preflight checksorSBMainWorkspace Busyerrors require terminating or uninstalling the app, rebooting the simulator, then cleaning and rebuilding.
Never print secrets, connection strings, app-setting values, developer IPs, or run-specific subscription, principal, or resource identifiers.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

