InstructionMITv1.0.0awesome-copilot

bicep-code-best-practices

Infrastructure as Code with Bicep

At a glance

Kind
Instruction · Ananke prompt
Reference
awesome-copilot/bicep-code-best-practices · ananke://prompt/awesome-copilot/bicep-code-best-practices@1.0.0
Applies to
**/*.bicep
Files
1 · 2.1 KB
How it's used
Instructions apply automatically to files matching their applyTo glob in GitHub Copilot. For Claude Code, reference the file from CLAUDE.md.

Where it fits

Task
Provision infrastructure
Lifecycle phase
Implementation
Role
DeveloperDevOps / SRE engineer
Domain
Infrastructure and cloud
Framework or tool
Bicep
Platform
Ananke PlexusGitHub Copilot
Needs
Nothing (text only)

Facets suggested from the item's own text and tags, not yet reviewed. Facets say where an item is relevant, not that it will run in your setup. How facets work

Checked by Dex

Verified, not self-reported: dex-trove 0.3.16 installed this item into each layout and checked that the tool can load it. Dex collects no download or usage data.

  • GitHub Copilot ✓ loads

Upstream metadata

Self-reported by the item's author; Dex shows it as written.

applyTo**/*.bicep

Documentation

View upstream ↗
Contents

Naming Conventions

  • When writing Bicep code, use lowerCamelCase for all names (variables, parameters, resources)
  • Use resource type descriptive symbolic names (e.g., ‘storageAccount’ not ‘storageAccountName’)
  • Avoid using ‘name’ in a symbolic name as it represents the resource, not the resource’s name
  • Avoid distinguishing variables and parameters by the use of suffixes

Structure and Declaration

  • Always declare parameters at the top of files with @description decorators
  • Use latest stable API versions for all resources
  • Use descriptive @description decorators for all parameters
  • Specify minimum and maximum character length for naming parameters

Parameters

  • Set default values that are safe for test environments (use low-cost pricing tiers)
  • Use @allowed decorator sparingly to avoid blocking valid deployments
  • Use parameters for settings that change between deployments

Variables

  • Variables automatically infer type from the resolved value
  • Use variables to contain complex expressions instead of embedding them directly in resource properties

Resource References

  • Use symbolic names for resource references instead of reference() or resourceId() functions
  • Create resource dependencies through symbolic names (resourceA.id) not explicit dependsOn
  • For accessing properties from other resources, use the ‘existing’ keyword instead of passing values through outputs

Resource Names

  • Use template expressions with uniqueString() to create meaningful and unique resource names
  • Add prefixes to uniqueString() results since some resources don’t allow names starting with numbers

Child Resources

  • Avoid excessive nesting of child resources
  • Use parent property or nesting instead of constructing resource names for child resources

Security

  • Never include secrets or keys in outputs
  • Use resource properties directly in outputs (e.g., storageAccount.properties.primaryEndpoints)

Documentation

  • Include helpful // comments within your Bicep files to improve readability