You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more information, see [Custom tagged union data type](./data-types.md#custom-tagged-union-data-type).
414
414
415
+
## Resource-derived types
416
+
417
+
Bicep allows you to derive types directly from Azure resource schemas using the `resourceInput<>` and `resourceOutput<>` constructs. Resource-derived types allow you to check parameters and variables against a portion of a resource body instead of with a custom type.
418
+
419
+
Templates can reuse resource types wherever a type is expected:
420
+
421
+
```bicep
422
+
resourceInput<'type@version'>
423
+
```
424
+
425
+
`resourceInput<>`: Represents the writable properties of a resource type, stripping away any properties marked as WriteOnly in the ARM schema. It uses the type that you would need to pass in to the resource declaration.
426
+
427
+
```bicep
428
+
resourceOutput<'type@version'>
429
+
```
430
+
431
+
`resourceOutput<>`: Represents the readable properties of a resource type, stripping away any properties marked as ReadOnly in the ARM schema. It matches the type of value returned after the resource is provisioned.
432
+
433
+
You can apply `resourceInput<>` to extract only a part of a resource schema. For example, to strongly type a variable or parameter based on just the `kind` or `properties` of a storage account:
434
+
435
+
```bicep
436
+
type accountKind = resourceInput<'Microsoft.Storage/storageAccounts@2024-01-01'>.kind
The following example shows how to use `resourceInput<>` to create a strongly typed parameter based on the `properties` of a storage account resource. This allows you to define a parameter that matches the writable properties of a storage account, such as `accessTier`, `minimumTlsVersion`, and others:
446
+
447
+
```bicep
448
+
// Strongly typed variable using the .properties path of a storage account
Unlike user-defined data types, resource-derived types are checked by Bicep when editing or compiling a file, but they are not checked by the ARM service.
469
+
415
470
## Related content
416
471
417
472
For a list of the Bicep data types, see [Data types](./data-types.md).
0 commit comments