スキル一覧に戻る
johnlokerse

converting-to-strong-types

by johnlokerse

This repository contains agent modes, prompt files and SKILLS for Azure Bicep

5🍴 1📅 2026年1月22日
GitHubで見るManusで実行

SKILL.md


name: converting-to-strong-types description: Converts loosely typed Bicep parameters using object or array to strongly typed alternatives like string[], user-defined types, or resource-derived types. Use when user mentions type safety, weak typing, object parameters, array parameters, resourceInput, resourceOutput, or asks to improve parameter definitions.

Converting to Strong Types

Replaces loose object and array parameter types with strong alternatives for compile-time validation and autocompletion.

Conversion Workflow

  1. Identify loose types

    • Search for param <name> object and param <name> array declarations.
  2. Analyze parameter usage

    • Examine how the parameter is used in the template to determine expected structure.
  3. Choose conversion strategy

PatternStrategy
Array of primitivesstring[], int[], bool[]
Array with constrained values('value1' | 'value2')[]
Object matching resource propertyresourceInput<'Type@Version'>.properties.X
Custom object structureUser-defined type with type keyword
Array of objectsUser-defined type with [] suffix
  1. Define types and update parameters

    • Place type definitions above parameters.
  2. Validate

    • Run command bicep build <.bicep file> --stdout --no-restore to verify syntax and type correctness.

Quick Reference

Simple Arrays

// Before
param addresses array

// After
param addresses string[]

Union Types (Constrained Values)

param environments ('dev' | 'staging' | 'prod')[]
param skuName 'Standard_LRS' | 'Premium_LRS'

User-Defined Types

type subnetType = {
  name: string
  addressPrefix: string
  nsgId: string?  // Optional property
}

param subnets subnetType[]

Type Best Practices

  • Use ? for optional properties: description: string?
  • Use @sealed() to prevent extra properties at deployment
  • Use @description() on types and properties
  • Use constraints: @minLength(), @maxLength(), @minValue(), @maxValue()
  • Compose complex types from simpler types

MCP Tools

ToolPurpose
Bicep:get_bicep_best_practicesCurrent best practices
Bicep:get_az_resource_type_schemaSchema for resource-derived types
Bicep:list_az_resource_types_for_providerAvailable types and API versions
Bicep:list_avm_metadataMetadata for Azure Verified Modules

Edge Cases

Dynamic objects (unknown keys): Use wildcard { *: string }

Mixed-type arrays: Use union (string | int | bool)[]

Optionality and backwards compatibility: Use optional types ? for new properties

Resource-Derived Types

Use resourceInput<> and resourceOutput<> to derive types directly from Azure resource schemas. Prioritise this approach over custom user-defined types.

Syntax

resourceInput<'<resourceType>@<apiVersion>'>   // Writable properties
resourceOutput<'<resourceType>@<apiVersion>'>  // Readable properties (includes computed)

When to Use

  • Parameter must match resource property structure exactly
  • Want to avoid maintaining custom types that mirror resource properties

Examples

Full Properties Block

param storageAccountProps resourceInput<'Microsoft.Storage/storageAccounts@2023-01-01'>.properties = {
  accessTier: 'Hot'
  minimumTlsVersion: 'TLS1_2'
  allowBlobPublicAccess: false
  supportsHttpsTrafficOnly: true
}

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: 'mystorageacct'
  location: resourceGroup().location
  sku: { name: 'Standard_LRS' }
  kind: 'StorageV2'
  properties: storageAccountProps
}

Output Types

output endpoints resourceOutput<'Microsoft.Storage/storageAccounts@2024-01-01'>.properties.primaryEndpoints

Do not do this

Do not use a type definition for resource-derived types but define them directly in parameters or outputs.

type managedRulesDefinitionType = resourceInput<'Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies@2024-07-01'>.properties.managedRules
type customRulesType = resourceInput<'Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies@2024-07-01'>.properties.customRules
type policySettingsType = resourceInput<'Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies@2024-07-01'>.properties.policySettings
type wafPolicyTagsType = resourceInput<'Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies@2024-07-01'>.tags

スコア

総合スコア

45/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です