Import Bicep namespaces

This article describes the syntax you use to import user-defined data types and the Bicep namespaces including the Bicep extensibility providers.

Import user-defined data types (Preview)

Bicep version 0.21.1 or newer is required to use this feature. The experimental flag compileTimeImports must be enabled from the Bicep config file.

The syntax for importing user-defined data type is:

import {<user-defined-data-type-name>, <user-defined-data-type-name>, ...} from '<bicep-file-name>'

or with wildcard syntax:

import * as <namespace> from '<bicep-file-name>'

You can mix and match the two preceding syntaxes.

Only user-defined data types that bear the @export() decorator can be imported. Currently, this decorator can only be used on type statements.

Imported types can be used anywhere a user-defined type might be, for example, within the type clauses of type, param, and output statements.



type myString = string

type myInt = int


import * as myImports from 'myTypes.bicep'
import {myInt} from 'myTypes.bicep'

param exampleString myImports.myString = 'Bicep'
param exampleInt myInt = 3

output outString myImports.myString = exampleString
output outInt myInt = exampleInt

Import namespaces and extensibility providers

The syntax for importing the namespaces is:

import 'az@1.0.0'
import 'sys@1.0.0'

Both az and sys are Bicep built-in namespaces. They are imported by default. For more information about the data types and the functions defined in az and sys, see Data types and Bicep functions.

The syntax for importing Bicep extensibility providers is:

import '<provider-name>@<provider-version>' with {

For an example, see Bicep extensibility Kubernetes provider.

Next steps