From 31a84e4b383267b3494302f0a521c38acbe99472 Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:10:32 +0000 Subject: [PATCH 01/12] Add README.md for Azure Bicep Imports and Exports examples --- bicep-examples/imports-exports/README.md | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 bicep-examples/imports-exports/README.md diff --git a/bicep-examples/imports-exports/README.md b/bicep-examples/imports-exports/README.md new file mode 100644 index 0000000..765c261 --- /dev/null +++ b/bicep-examples/imports-exports/README.md @@ -0,0 +1,42 @@ +# Azure Bicep - Imports and Exports + +## Introduction + +The import and export feature in Bicep allows you to resuse commonly used variables. Exports allows you to define variables to be exported for use elsewhere in other templates. Imports let you pull in variables pre-defined elsewhere, so you don’t have to duplicate code. + +This approach keeps your templates tidy, consistent, and easier to manage as your environment grows. + +## 📃 Benefits of User Defined Types + +✅ Centraliation: Allows you to define commonly repeated variables and user defined types in one file that many Bicep templates can reuse. + +✅ Reduces repetition: Variables you may be repeating in each Bicep template can now be moved centrally, reducing repetition and streamlining templates. + +✅ Resuability: The exports can now be used across multiple projects and templates allowing much greater resuability for standards and common values. + +## Export Example + +## Import Example + +## 🚀 Deployment + +> [!NOTE] +> You need to have a resource group deployed before trying this out. + +In VisualStudio Code open a terminal and run: + +CLI + +```bash +az login +az account set --subscription 'subscription name or id' +az deployment group create -g 'your-rg' --confirm-with-what-if -f '.\main.bicep' -p 'main.bicepparam' +``` + +or PowerShell + +```powershell +Connect-AzAccount +Set-AzContext -Subscription "subscription name or id" +New-AzResourceGroupDeployment -Confirm -ResourceGroup "your-rg" -TemplateFile "main.bicep" -TemplateParameterFile "main.bicepparam" +``` From 2582bba7557ff6050ff88609d9e71ea76651d788 Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:25:50 +0000 Subject: [PATCH 02/12] Enhance README.md with detailed export examples for Azure Bicep variables --- bicep-examples/imports-exports/README.md | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/bicep-examples/imports-exports/README.md b/bicep-examples/imports-exports/README.md index 765c261..ab89571 100644 --- a/bicep-examples/imports-exports/README.md +++ b/bicep-examples/imports-exports/README.md @@ -16,8 +16,57 @@ This approach keeps your templates tidy, consistent, and easier to manage as you ## Export Example +In the exports example, you can define what variables or types you want to be available to be 'imported' by defining an @export() decorator next to them. + +For example, a `shared.bicep` file could reside in the root of your Bicep repository with these commonly used variables: + +```bicep +// shared.bicep with common vars + +@export() +@description('Primary Azure region.') +var region = 'uksouth' + +@export() +@description('Azure Landing Zone HUB subscription Id') +var alzHubSubscriptionId = '0000-0000-0000-000' + +@export() +@description('Azure Landing Zone HUB Resource Group') +var alzHubResourceGroup = 'rg-hub' + +@export() +@description('Branch Office Public IP for network ACLs') +var branchOfficePip = '82.102.11.90' +``` + +Entra example: + +```bicep +@export() +@description('Common Entra Security Group(s) for RBAC') +var entraSecurityGroups = [ + { + displayName: 'SG_Cloud_Team', + objectId: '11111111-1111-1111-1111-111111111111' + }, + { + displayName: 'SG_Security_Team', + objectId: '22222222-2222-2222-2222-222222222222' + }, + { + displayName: 'SG_Dev_Team', + objectId: '33333333-3333-3333-3333-333333333333' + } +] +``` ## Import Example +```bicep +import * as shared '../shared.bicep' + + + ## 🚀 Deployment > [!NOTE] From 79ac79761f8553aeede9fe54b1e9b0b513e8ea66 Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Mon, 28 Apr 2025 12:54:32 +0000 Subject: [PATCH 03/12] Add shared.bicep with Entra Security Groups and location variable definitions --- bicep-examples/imports-exports/main.bicep | 13 +++++++++++++ bicep-examples/imports-exports/shared.bicep | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 bicep-examples/imports-exports/main.bicep create mode 100644 bicep-examples/imports-exports/shared.bicep diff --git a/bicep-examples/imports-exports/main.bicep b/bicep-examples/imports-exports/main.bicep new file mode 100644 index 0000000..3fe4efe --- /dev/null +++ b/bicep-examples/imports-exports/main.bicep @@ -0,0 +1,13 @@ + +// Imports +import * as shared from 'shared.bicep' +// import { location } as location from 'shared.bicep' to only import a specific var or type from the file. + +module entraRbac 'br/public:avm/ptn/authorization/role-assignment:0.2.2' = { + name: '${uniqueString(deployment().name, location)}' + params: { + principalId: shared.entraSecurityGroups.SG_Cloud_Team.objectId + roleDefinitionIdOrName: 'Reader' + subscriptionId: subscription().subscriptionId + } + } \ No newline at end of file diff --git a/bicep-examples/imports-exports/shared.bicep b/bicep-examples/imports-exports/shared.bicep new file mode 100644 index 0000000..3cdb73d --- /dev/null +++ b/bicep-examples/imports-exports/shared.bicep @@ -0,0 +1,20 @@ +@export() +@description('Common Entra Security Group(s) for RBAC') +var entraSecurityGroups = [ + SG_Cloud_Team: { + displayName: 'SG_Cloud_Team', + objectId: '11111111-1111-1111-1111-111111111111' + } + SG_Security_Team: { + displayName: 'SG_Security_Team', + objectId: '22222222-2222-2222-2222-222222222222' + } + SG_Dev_Team: { + displayName: 'SG_Dev_Team', + objectId: '33333333-3333-3333-3333-333333333333' + } +] + +@export() +@description('The Primary Azure Region location') +var location = 'uksouth' \ No newline at end of file From 2087a24386e799184980ac99dfcd0a1538c91269 Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Thu, 1 May 2025 15:52:19 +0000 Subject: [PATCH 04/12] Refactor shared.bicep structure and update README.md with new variable definitions for Entra Security Groups and location --- bicep-examples/imports-exports/README.md | 48 +++++++++--------- bicep-examples/imports-exports/main.bicep | 56 ++++++++++++++++++--- bicep-examples/imports-exports/shared.bicep | 16 +++--- 3 files changed, 81 insertions(+), 39 deletions(-) diff --git a/bicep-examples/imports-exports/README.md b/bicep-examples/imports-exports/README.md index ab89571..7c2b38c 100644 --- a/bicep-examples/imports-exports/README.md +++ b/bicep-examples/imports-exports/README.md @@ -22,22 +22,13 @@ For example, a `shared.bicep` file could reside in the root of your Bicep reposi ```bicep // shared.bicep with common vars - -@export() -@description('Primary Azure region.') -var region = 'uksouth' - -@export() -@description('Azure Landing Zone HUB subscription Id') -var alzHubSubscriptionId = '0000-0000-0000-000' - @export() -@description('Azure Landing Zone HUB Resource Group') -var alzHubResourceGroup = 'rg-hub' +@description('The Primary Azure Region location') +var location = 'uksouth' @export() -@description('Branch Office Public IP for network ACLs') -var branchOfficePip = '82.102.11.90' +@description('Branch Office Public IP') +var branchOfficePublicIP = '82.110.72.90' ``` Entra example: @@ -45,26 +36,33 @@ Entra example: ```bicep @export() @description('Common Entra Security Group(s) for RBAC') -var entraSecurityGroups = [ - { - displayName: 'SG_Cloud_Team', +var entraSecurityGroups = { + SG_Cloud_Team: { + displayName: 'SG_Cloud_Team' objectId: '11111111-1111-1111-1111-111111111111' - }, - { - displayName: 'SG_Security_Team', + } + SG_Security_Team: { + displayName: 'SG_Security_Team' objectId: '22222222-2222-2222-2222-222222222222' - }, - { - displayName: 'SG_Dev_Team', + } + SG_Dev_Team: { + displayName: 'SG_Dev_Team' objectId: '33333333-3333-3333-3333-333333333333' } -] +} ``` ## Import Example ```bicep -import * as shared '../shared.bicep' - +import * as shared from 'shared.bicep' +... +roleAssignments: [ + { + principalId: shared.entraSecurityGroups.SG_Cloud_Team.objectId // Using imported Entra Security Group Object ID + roleDefinitionIdOrName: 'Contributor' + } + ] +``` ## 🚀 Deployment diff --git a/bicep-examples/imports-exports/main.bicep b/bicep-examples/imports-exports/main.bicep index 3fe4efe..430b7b4 100644 --- a/bicep-examples/imports-exports/main.bicep +++ b/bicep-examples/imports-exports/main.bicep @@ -1,13 +1,53 @@ -// Imports +targetScope = 'subscription' + +// MARK: Imports import * as shared from 'shared.bicep' // import { location } as location from 'shared.bicep' to only import a specific var or type from the file. -module entraRbac 'br/public:avm/ptn/authorization/role-assignment:0.2.2' = { - name: '${uniqueString(deployment().name, location)}' - params: { - principalId: shared.entraSecurityGroups.SG_Cloud_Team.objectId - roleDefinitionIdOrName: 'Reader' - subscriptionId: subscription().subscriptionId +// MARK: Variables +var location = shared.location // using central value from shared.bicep +var rgName = 'rg-bicepify-demo' +var keyVaultName = 'kv-bicepify-demo' + +// MARK: RBAC Entra import example +module resourceGroupShared 'br/public:avm/res/resources/resource-group:0.4.1' = { + name: '${uniqueString(deployment().name, location)}-${rgName}' + params:{ + name: rgName + location: location + roleAssignments: [ + { + principalId: shared.entraSecurityGroups.SG_Cloud_Team.objectId // Using imported Entra Security Group Object ID + roleDefinitionIdOrName: 'Contributor' + } + ] + } +} + +// MARK: Key Vault +module keyVault 'br/public:avm/res/key-vault/vault:0.12.1' = { + name: '${uniqueString(deployment().name, location)}-${keyVaultName}' + scope: resourceGroup(rgName) + params: { + name: keyVaultName + location: location + sku: 'standard' + publicNetworkAccess: '' + enableSoftDelete: true + enableRbacAuthorization: true + enablePurgeProtection: true + softDeleteRetentionInDays: 90 + networkAcls: { + defaultAction: 'Deny' + bypass: 'AzureServices' + virtualNetworkRules: [] + ipRules: [ + { + value: shared.branchOfficePublicIP // using central import value from shared.bicep + action: 'Allow' + } + ] } - } \ No newline at end of file + } +} diff --git a/bicep-examples/imports-exports/shared.bicep b/bicep-examples/imports-exports/shared.bicep index 3cdb73d..5a7405b 100644 --- a/bicep-examples/imports-exports/shared.bicep +++ b/bicep-examples/imports-exports/shared.bicep @@ -1,20 +1,24 @@ @export() @description('Common Entra Security Group(s) for RBAC') -var entraSecurityGroups = [ +var entraSecurityGroups = { SG_Cloud_Team: { - displayName: 'SG_Cloud_Team', + displayName: 'SG_Cloud_Team' objectId: '11111111-1111-1111-1111-111111111111' } SG_Security_Team: { - displayName: 'SG_Security_Team', + displayName: 'SG_Security_Team' objectId: '22222222-2222-2222-2222-222222222222' } SG_Dev_Team: { - displayName: 'SG_Dev_Team', + displayName: 'SG_Dev_Team' objectId: '33333333-3333-3333-3333-333333333333' } -] +} @export() @description('The Primary Azure Region location') -var location = 'uksouth' \ No newline at end of file +var location = 'uksouth' + +@export() +@description('Branch Office Public IP') +var branchOfficePublicIP = '82.110.72.90' From 9b518702b744ff7cf20833f5cb253d8116d0214a Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Fri, 2 May 2025 21:17:02 +0100 Subject: [PATCH 05/12] Update README.md --- bicep-examples/imports-exports/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/bicep-examples/imports-exports/README.md b/bicep-examples/imports-exports/README.md index 7c2b38c..05579ce 100644 --- a/bicep-examples/imports-exports/README.md +++ b/bicep-examples/imports-exports/README.md @@ -4,8 +4,6 @@ The import and export feature in Bicep allows you to resuse commonly used variables. Exports allows you to define variables to be exported for use elsewhere in other templates. Imports let you pull in variables pre-defined elsewhere, so you don’t have to duplicate code. -This approach keeps your templates tidy, consistent, and easier to manage as your environment grows. - ## 📃 Benefits of User Defined Types ✅ Centraliation: Allows you to define commonly repeated variables and user defined types in one file that many Bicep templates can reuse. From a545a970ed01f99a423a5944903da9f2f7d2c698 Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Sun, 4 May 2025 19:17:40 +0000 Subject: [PATCH 06/12] typo --- bicep-examples/imports-exports/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bicep-examples/imports-exports/README.md b/bicep-examples/imports-exports/README.md index 7c2b38c..689ee0b 100644 --- a/bicep-examples/imports-exports/README.md +++ b/bicep-examples/imports-exports/README.md @@ -55,6 +55,8 @@ var entraSecurityGroups = { ```bicep import * as shared from 'shared.bicep' + +module rg 'br/public:avm/res/resources/resource-group:0.4.1' = { ... roleAssignments: [ { @@ -86,4 +88,4 @@ or PowerShell Connect-AzAccount Set-AzContext -Subscription "subscription name or id" New-AzResourceGroupDeployment -Confirm -ResourceGroup "your-rg" -TemplateFile "main.bicep" -TemplateParameterFile "main.bicepparam" -``` +``` \ No newline at end of file From 9f2d6c9fa859bdb1fb7e599286880f0c3d137933 Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Sun, 4 May 2025 19:27:42 +0000 Subject: [PATCH 07/12] Update README.md and shared.bicep with additional examples and variable definitions --- bicep-examples/imports-exports/README.md | 31 ++++++++++++++++++--- bicep-examples/imports-exports/shared.bicep | 4 +++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/bicep-examples/imports-exports/README.md b/bicep-examples/imports-exports/README.md index 1ece2a4..7aede7f 100644 --- a/bicep-examples/imports-exports/README.md +++ b/bicep-examples/imports-exports/README.md @@ -4,6 +4,10 @@ The import and export feature in Bicep allows you to resuse commonly used variables. Exports allows you to define variables to be exported for use elsewhere in other templates. Imports let you pull in variables pre-defined elsewhere, so you don’t have to duplicate code. +Instead of repeatedly typing your variable value in every new Bicep file for example, `var budgetAlertEmail = 'dan@rios.engineer'` you can store this value centrally and import it into your template instead. + +This can be used for many use cases beyond the examples here (subscription Ids, service principal ids, app registrations, private DNS zone FQDNs, etc.). + ## 📃 Benefits of User Defined Types ✅ Centraliation: Allows you to define commonly repeated variables and user defined types in one file that many Bicep templates can reuse. @@ -12,7 +16,7 @@ The import and export feature in Bicep allows you to resuse commonly used variab ✅ Resuability: The exports can now be used across multiple projects and templates allowing much greater resuability for standards and common values. -## Export Example +## Export Examples In the exports example, you can define what variables or types you want to be available to be 'imported' by defining an @export() decorator next to them. @@ -29,7 +33,7 @@ var location = 'uksouth' var branchOfficePublicIP = '82.110.72.90' ``` -Entra example: +### Entra example: ```bicep @export() @@ -49,8 +53,8 @@ var entraSecurityGroups = { } } ``` -## Import Example - +## Import Examples +### Entra ObjectId ```bicep import * as shared from 'shared.bicep' @@ -64,6 +68,25 @@ roleAssignments: [ ] ``` +### ACL IP Example: +```bicep +import * as shared from 'shared.bicep' + +module keyVault 'br/public:avm/res/key-vault/vault:0.12.1' = { +.... + networkAcls: { + defaultAction: 'Deny' + bypass: 'AzureServices' + virtualNetworkRules: [] + ipRules: [ + { + value: shared.branchOfficePublicIP // using central import value from shared.bicep + action: 'Allow' + } + ] + } + } +``` ## 🚀 Deployment diff --git a/bicep-examples/imports-exports/shared.bicep b/bicep-examples/imports-exports/shared.bicep index 5a7405b..687f540 100644 --- a/bicep-examples/imports-exports/shared.bicep +++ b/bicep-examples/imports-exports/shared.bicep @@ -22,3 +22,7 @@ var location = 'uksouth' @export() @description('Branch Office Public IP') var branchOfficePublicIP = '82.110.72.90' + +@export() +@description('Azure Websites Private DNS Zone FQDN') +var azureWebsitesPrivateDnsZone = 'privatelink.azurewebsites.net' From 0aa30b62f07bb76379463f8f705190f831bf4ccd Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Sun, 4 May 2025 20:14:49 +0000 Subject: [PATCH 08/12] Update README.md for clarity on imports/exports and refine main.bicep configuration for Key Vault --- bicep-examples/imports-exports/README.md | 11 ++++++----- bicep-examples/imports-exports/main.bicep | 6 +----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/bicep-examples/imports-exports/README.md b/bicep-examples/imports-exports/README.md index 7aede7f..e74619b 100644 --- a/bicep-examples/imports-exports/README.md +++ b/bicep-examples/imports-exports/README.md @@ -2,7 +2,7 @@ ## Introduction -The import and export feature in Bicep allows you to resuse commonly used variables. Exports allows you to define variables to be exported for use elsewhere in other templates. Imports let you pull in variables pre-defined elsewhere, so you don’t have to duplicate code. +The import and export feature in Bicep allows you to resuse commonly used variables and types. Exports allow you to define variables to be imported for use elsewhere in other templates. Imports let you pull in variables pre-defined elsewhere, so you don’t have to duplicate the same code values in every bicep file. Instead of repeatedly typing your variable value in every new Bicep file for example, `var budgetAlertEmail = 'dan@rios.engineer'` you can store this value centrally and import it into your template instead. @@ -14,13 +14,13 @@ This can be used for many use cases beyond the examples here (subscription Ids, ✅ Reduces repetition: Variables you may be repeating in each Bicep template can now be moved centrally, reducing repetition and streamlining templates. -✅ Resuability: The exports can now be used across multiple projects and templates allowing much greater resuability for standards and common values. +✅ Resuability: The exports can now be used across multiple projects and templates allowing much greater resuability for standards and common values. This can also help reduce configuration errors. ## Export Examples In the exports example, you can define what variables or types you want to be available to be 'imported' by defining an @export() decorator next to them. -For example, a `shared.bicep` file could reside in the root of your Bicep repository with these commonly used variables: +For example, a `shared.bicep` file could reside in the root of your Bicep folder within your repository, with these commonly used variables as an example: ```bicep // shared.bicep with common vars @@ -70,8 +70,9 @@ roleAssignments: [ ### ACL IP Example: ```bicep -import * as shared from 'shared.bicep' - +import * as shared from 'shared.bicep' +// or you can only import the required variable vs all available via +// import { branchOfficePublicIP } as branchOfficePublicIP from 'shared.bicep' as an example module keyVault 'br/public:avm/res/key-vault/vault:0.12.1' = { .... networkAcls: { diff --git a/bicep-examples/imports-exports/main.bicep b/bicep-examples/imports-exports/main.bicep index 430b7b4..4f4f57a 100644 --- a/bicep-examples/imports-exports/main.bicep +++ b/bicep-examples/imports-exports/main.bicep @@ -33,11 +33,7 @@ module keyVault 'br/public:avm/res/key-vault/vault:0.12.1' = { name: keyVaultName location: location sku: 'standard' - publicNetworkAccess: '' - enableSoftDelete: true - enableRbacAuthorization: true - enablePurgeProtection: true - softDeleteRetentionInDays: 90 + publicNetworkAccess: 'Disabled' // Selected Networking networkAcls: { defaultAction: 'Deny' bypass: 'AzureServices' From c81e8a357da873bf429869248828c6b26818f5ba Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Sun, 4 May 2025 20:18:32 +0000 Subject: [PATCH 09/12] Refine README.md for Public Bicep Registry section, correcting typos and enhancing clarity on Azure Verified Modules --- bicep-examples/consuming-modules/README.md | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/bicep-examples/consuming-modules/README.md b/bicep-examples/consuming-modules/README.md index d348920..71d4247 100644 --- a/bicep-examples/consuming-modules/README.md +++ b/bicep-examples/consuming-modules/README.md @@ -8,18 +8,20 @@ If you're new to Bicep understanding the different ways to consume modules can b Please review the blog post to get an understanding on the pros & cons of each consumption method. These are based on real world experiences using all methods, straight from the battlefield. -## Public Bicep Registry +## Public Bicep Registry (Azure Verfieid Modules) The public registry can be consumed directly from anywhere with ease and has quick adoption with no start up overhead as the modules are centrally stored by the team. -```javascript -module public_registry 'br/public:compute/function-app:2.0.1' = { - name: 'public_registry_example' +The concept of AVM allows these modules to accelerate teams to deploy with Bicep, using best practice & aligned to the Well-Architected Framework that is managed by Microsoft so you don't have to maintain the modules yourselves. Be sure to check out more on [AVM](https://azure.github.io/Azure-Verified-Modules/overview/introduction/). + +```bicep +module KeyVault 'br/public:avm/res/key-vault/vault:0.7.0' = { + name: 'avm_exmple' params: { - name: 'example-func-001' + name: 'kvName' location: 'uksouth' - storageAccountName: 'stsomestorageaccount001' - storageAccountResourceGroup: 'rg-some-rg-here' + sku: 'standard' + enableSoftDelete: true } } ``` @@ -88,9 +90,3 @@ module inline_module 'modules/inline/customModule.bicep' = { } } ``` - -## Azure Verified Modules / Azure Bicep Public Registry - -[AVM](https://azure.github.io/Azure-Verified-Modules/faq/#what-is-happening-to-existing-initiatives-like-carml-and-tfvm) - -This is still in development at the time of writing. However, there is a new initiative by the IaC teams at Microsoft to present what good Infrastructure-as-Code looks like. The idea here will be these modules will accelerate teams to deploy with Bicep, using best practice & aligned to the Well-Architected Framework. From 1a686f7f23aa303713a1f820a4a858cdc6be6158 Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Mon, 5 May 2025 13:22:28 +0000 Subject: [PATCH 10/12] Fix typos and enhance clarity in README.md for Bicep imports and exports section --- bicep-examples/imports-exports/README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bicep-examples/imports-exports/README.md b/bicep-examples/imports-exports/README.md index e74619b..02a0ae9 100644 --- a/bicep-examples/imports-exports/README.md +++ b/bicep-examples/imports-exports/README.md @@ -2,11 +2,15 @@ ## Introduction -The import and export feature in Bicep allows you to resuse commonly used variables and types. Exports allow you to define variables to be imported for use elsewhere in other templates. Imports let you pull in variables pre-defined elsewhere, so you don’t have to duplicate the same code values in every bicep file. +The import and export feature in Bicep allows you to reuse commonly used variables and types efficiently. Exports enable you to define variables that can be imported for use in other templates, while imports allow you to pull in pre-defined variables—eliminating the need to duplicate code across multiple Bicep files. -Instead of repeatedly typing your variable value in every new Bicep file for example, `var budgetAlertEmail = 'dan@rios.engineer'` you can store this value centrally and import it into your template instead. +Instead of manually defining a variable in every new Bicep file, such as: -This can be used for many use cases beyond the examples here (subscription Ids, service principal ids, app registrations, private DNS zone FQDNs, etc.). + `var budgetAlertEmail = 'dan@rios.engineer'` + +You can store this value centrally and simply import it into your template when needed. + +This functionality extends beyond just variables (and types). It can be applied to various use cases, such as subscription IDs, service principal IDs, app registrations, and private DNS zone FQDNs and tons more. Helping maintain consistency and reducing repetitive code. ## 📃 Benefits of User Defined Types @@ -18,7 +22,7 @@ This can be used for many use cases beyond the examples here (subscription Ids, ## Export Examples -In the exports example, you can define what variables or types you want to be available to be 'imported' by defining an @export() decorator next to them. +In the exports example, you can define what variables or types you want to be available to be imported by defining an @export() decorator next to them. For example, a `shared.bicep` file could reside in the root of your Bicep folder within your repository, with these commonly used variables as an example: From c180ba0d0e1f3602bd4b3e15713886d64d536ffb Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Mon, 5 May 2025 13:26:02 +0000 Subject: [PATCH 11/12] Update MegaLinter workflow to use actions/checkout@v4 --- .github/workflows/mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index 1418c30..d37bf65 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -31,7 +31,7 @@ jobs: steps: # Git Checkout - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances From abf9985d76ecc4535a527e8d2500dd2eff488c66 Mon Sep 17 00:00:00 2001 From: Dan Rios <36534747+riosengineer@users.noreply.github.com> Date: Mon, 5 May 2025 13:27:20 +0000 Subject: [PATCH 12/12] Update MegaLinter workflow to use actions/upload-artifact@v4 --- .github/workflows/mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index d37bf65..8b8080f 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -54,7 +54,7 @@ jobs: # Upload MegaLinter artifacts - name: Archive production artifacts if: ${{ success() }} || ${{ failure() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: MegaLinter reports path: |