writing-bicep-templates
Skill124 starsChanged 7 months agoMITView on GitHub
Provides Bicep coding standards for Azure infrastructure in this repository. Use when writing or modifying Bicep files, configuring Container Apps, setting up RBAC, or working with Azure resources.
In this repository20 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- committing-codeSkill
- deploying-to-azureSkill
- implementing-chat-streamingSkill
- planning-featuresSkill
- researching-azure-ai-sdkSkill
- reviewing-documentationSkill
- syncing-mcp-serversSkill
- testing-cli-compatibilitySkill
- testing-with-playwrightSkill
- triaging-issuesSkill
- troubleshooting-authenticationSkill
- understanding-architectureSkill
- validating-deploymentsSkill
- validating-local-setupSkill
- validating-ui-featuresSkill
- writing-csharp-codeSkill
- writing-typescript-codeSkill
- writing-unit-tests-csharpSkill
- writing-unit-tests-typescriptSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
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 8
Goal: Create consistent, secure Azure infrastructure
- Very specific: line 12
Use resourceToken from uniqueString():
- Very specific: line 23
Always add @description() and use @allowed() for constrained values:
- Very specific: line 46
Use a user-assigned MI for ACR pull and OBO (avoids circular dependencies).
- Very specific: line 61
Use guid() for names + specify principalType:
- Distinctive: line 98
Use user-assigned MI for ACR pull (no admin credentials or secrets):
≈ “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
Bicep Coding Standards
Goal: Create consistent, secure Azure infrastructure
Naming Convention
Use resourceToken from uniqueString():
var token = toLower(uniqueString(subscription().id, environmentName, location))
name: '${abbrs.appContainerApps}web-${token}' // ca-web-abc123Exception: ACR requires alphanumeric only: cr${resourceToken}
Parameters
Always add @description() and use @allowed() for constrained values:
@description('Environment (dev, prod)')
param environmentName string
@description('Azure region')
@allowed(['eastus2', 'westus2'])
param location string = 'eastus2'Outputs
Expose key identifiers for azd and other modules:
output containerAppName string = containerApp.name
output webEndpoint string = 'https://${containerApp.properties.configuration.ingress.fqdn}'
output identityPrincipalId string = containerApp.identity.principalIdManaged Identity
Use a user-assigned MI for ACR pull and OBO (avoids circular dependencies). Create it in the infrastructure module so its principalId is available before the Container App:
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = {
name: '${abbrs.managedIdentityUserAssignedIdentities}web-${resourceToken}'
location: location
properties: { isolationScope: 'Regional' }
}
output managedIdentityPrincipalId string = managedIdentity.properties.principalIdAttach to Container App with identity: { type: 'UserAssigned', userAssignedIdentities: { '${miId}': {} } }. Use MI for ACR pull via registries: [{ server: acr.loginServer, identity: miId }].
RBAC Assignments
Use guid() for names + specify principalType:
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(resource.id, principalId, roleId)
properties: {
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleId)
principalId: principalId
principalType: 'ServicePrincipal'
}
}Container Apps
Key settings: System identity + scale-to-zero + HTTPS only:
resource containerApp 'Microsoft.App/containerApps@2023-05-01' = {
identity: { type: 'UserAssigned', userAssignedIdentities: { '${userAssignedIdentityId}': {} } }
properties: {
configuration: {
ingress: {
external: true
targetPort: 8080
allowInsecure: false
}
}
template: {
scale: { minReplicas: 0, maxReplicas: 3 }
}
}
}ACR Pull Pattern
Use user-assigned MI for ACR pull (no admin credentials or secrets):
registries: [{
server: containerRegistry.properties.loginServer
identity: userAssignedIdentityId // MI with AcrPull role
}]Validation
az bicep build --file main.bicep
az deployment group what-if --template-file main.bicepProject-Specific: Module Hierarchy
main.bicep (subscription scope)
├─ Resource group
├─ main-infrastructure.bicep (ACR + Container Apps Env + Log Analytics + User-Assigned MI)
├─ entra-app.bicep (SPA app + conditional OBO backend app with FIC + admin consent)
├─ main-app.bicep (Container App with MI-based ACR pull)
└─ RBAC (Cognitive Services User role via postprovision CLI)Project-Specific: Container App Configuration
resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
identity: {
type: 'UserAssigned'
userAssignedIdentities: { '${userAssignedIdentityId}': {} }
}
properties: {
managedEnvironmentId: containerAppsEnvironmentId
configuration: {
ingress: {
external: true
targetPort: 8080
allowInsecure: false
}
registries: [{
server: containerRegistry.properties.loginServer
identity: userAssignedIdentityId // MI-based pull, no secrets
}]
}
template: {
containers: [{
name: 'web'
image: containerImage
env: containerEnv // Base env + conditional OBO env
resources: { cpu: json('0.5'), memory: '1Gi' }
}]
scale: { minReplicas: 0, maxReplicas: 3 }
}
}
}
output fqdn string = containerApp.properties.configuration.ingress.fqdn
output identityPrincipalId string = containerApp.identity.principalIdRelated Skills
- deploying-to-azure - Deployment commands and hook workflow
- writing-csharp-code - Backend configuration for Container Apps
- troubleshooting-authentication - RBAC and managed identity debugging
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.

