Skip to content

Prompting Best Practices

InterfaceBest For
Inline suggestions (Tab)Completing code snippets, variable names, repetitive blocks
Copilot ChatQuestions, generating larger sections, debugging
Agentic InfraOps AgentsMulti-step workflows, end-to-end projects

Do not ask for an entire landing zone in one prompt. Start small and iterate.

❌ Create a complete Azure landing zone with networking, identity, security,
and governance
✅ Create a hub VNet with:
- Address space: 10.0.0.0/16
- Subnets: GatewaySubnet, AzureFirewallSubnet, SharedServicesSubnet
- NSG on SharedServicesSubnet with deny-all default
❌ Create a storage account
✅ Create a Bicep module for Azure Storage with:
- SKU: Standard_ZRS
- HTTPS only, TLS 1.2 minimum
- No public blob access
- Soft delete: 30 days
✅ Create a Terraform module for Azure Storage with:
- SKU: Standard_ZRS
- HTTPS only, TLS 1.2 minimum
- No public blob access
- Soft delete: 30 days

Include target environment, compliance requirements, naming conventions, and region in every prompt:

Create a Bicep module for Azure SQL Database.
Context:
- Environment: production
- Compliance: HIPAA (audit logging required)
- Region: swedencentral
- Naming: sql-{projectName}-{environment}-{uniqueSuffix}
- Authentication: Azure AD only (no SQL auth)
Requirements:
- Zone redundant
- Geo-replication to germanywestcentral
- 35-day backup retention
VariablePurposeExample
@workspaceSearch entire workspace@workspace Find all Key Vault references
#fileReference specific file#file:main.bicep Explain this module
#selectionCurrent selectionSelect code, then ask about it
#terminalLastCommandLast terminal output#terminalLastCommand Why did this fail?

Explain Then Generate:

First, explain best practices for App Service networking with private endpoints.
Then, create a Bicep module that implements these practices.

Review Then Fix:

Review this Bicep template for:
1. Security issues
2. Well-Architected Framework alignment
3. Missing outputs
Then provide a corrected version.

Compare Approaches:

Show two approaches for deploying Azure Container Apps:
1. Using native Bicep resources
2. Using Azure Verified Modules (AVM)
Compare pros/cons for a production HIPAA workload.

Incremental Refinement:

Prompt 1: Create a basic VNet module
Prompt 2: Add NSGs to each subnet with deny-all default
Prompt 3: Add diagnostic settings for all NSG flow logs
Prompt 4: Make the address space configurable via parameters
Anti-PatternProblemBetter Approach
”Generate everything”Output too broadBreak into one module per prompt: VNet, then NSGs, then diagnostics
Accepting without reviewBugs, security issuesAlways run bicep lint / terraform validate and review for hardcoded secrets
Ignoring contextGeneric suggestionsOpen relevant files first, use @workspace and #file: references
One-shot complex promptsIncomplete outputIterate: start with skeleton, add security, add monitoring, add parameters
Not providing examplesInconsistent formattingShow the naming pattern or module structure you want the agent to follow
CheckWhy
API versions are recent (2023+)Older versions lack features
supportsHttpsTrafficOnly: trueSecurity baseline
minimumTlsVersion: 'TLS1_2'Compliance requirement
Unique names use uniqueString() / random_stringAvoid naming collisions
Outputs include both ID and nameDownstream modules need both
Terminal window
# Validate Bicep syntax
bicep build main.bicep
# Lint for best practices
bicep lint main.bicep
# Preview Bicep deployment
az deployment group what-if \
--resource-group myRG \
--template-file main.bicep
# Validate Terraform syntax
terraform fmt -check
terraform validate
# Lint Terraform with TFLint
tflint --init && tflint
# Preview Terraform deployment
terraform plan -out=tfplan