Skip to content

Update-BylawAliasCache

SYNOPSIS

Refreshes the Azure Policy alias snapshot that Bylaw validates field names against.

SYNTAX

Update-BylawAliasCache [[-OutputPath] <String>] [[-ResourceType] <String[]>] [[-Namespace] <String[]>]
 [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

Reads alias metadata with Get-AzPolicyAlias -ListAvailable (read-only) and writes a Bylaw alias snapshot. Resource types with no aliases, such as Microsoft.Resources/subscriptions and resourceGroups, are included with none, so policies can target them; API endpoints with no aliases, such as .../operations and .../checkNameAvailability, are left out. Requires Az.Resources and a signed-in context (Connect-AzAccount). Compiling policies never needs Az; it uses the snapshot offline (ADR-0008).

By default the snapshot is written to the user cache ($HOME/.bylaw/aliases.json), which Build-Bylaw uses in preference to the snapshot bundled with the module.

EXAMPLES

EXAMPLE 1

Connect-AzAccount
Update-BylawAliasCache

EXAMPLE 2

Update-BylawAliasCache -ResourceType 'Microsoft.Storage/storageAccounts' -OutputPath ./aliases.json

PARAMETERS

-OutputPath

Where to write the snapshot. Defaults to the user cache.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: (Get-BylawUserAliasCachePath)
Accept pipeline input: False
Accept wildcard characters: False

-ResourceType

Only include these resource types, e.g. 'Microsoft.Storage/storageAccounts'.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Namespace

Only include these resource provider namespaces, e.g. 'Microsoft.Storage'.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

Return a summary object (path, type count, alias count).

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS

NOTES