From 0e393248d6a38176763ee3cc53dd78e14f7e334e Mon Sep 17 00:00:00 2001 From: Rick Su Date: Tue, 19 Mar 2024 18:05:55 +1100 Subject: [PATCH 1/9] Add Bicep User-defined Data Type Rule --- categories/software-engineering/index.md | 1 + .../rules-to-better-infrastructure-as-code.md | 17 ++++++ .../rule.md | 56 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 categories/software-engineering/rules-to-better-infrastructure-as-code.md create mode 100644 rules/bicep-do-you-use-user-defined-data-types/rule.md diff --git a/categories/software-engineering/index.md b/categories/software-engineering/index.md index e2ec8091c32..f52523b59ce 100644 --- a/categories/software-engineering/index.md +++ b/categories/software-engineering/index.md @@ -7,6 +7,7 @@ index: - rules-to-better-net8-migrations - rules-to-better-architecture-and-code-review - rules-to-better-azure +- rules-to-better-infrastructure-as-code - rules-to-better-blazor - rules-to-better-mvc - rules-to-better-bots diff --git a/categories/software-engineering/rules-to-better-infrastructure-as-code.md b/categories/software-engineering/rules-to-better-infrastructure-as-code.md new file mode 100644 index 00000000000..7ef0d54d779 --- /dev/null +++ b/categories/software-engineering/rules-to-better-infrastructure-as-code.md @@ -0,0 +1,17 @@ +--- +type: category +title: Rules to Better Infrastructure as Code (IaC) +guid: 2948bfca-605b-4e67-974a-3cec1c7aa741 +uri: rules-to-better-infrastructure-as-code +experts: https://www.ssw.com.au/people/?skill=bicep +consulting: https://ssw.com.au/consulting/azure +index: +- bicep-user-defined-data-types + +--- + +Infrastructure as code (IaC) uses DevOps methodology and versioning with a descriptive model to define and deploy infrastructure, such as networks, virtual machines, load balancers, and connection topologies. Just as the same source code always generates the same binary, an IaC model generates the same environment every time it deploys. + +Need help with Microsoft Azure? Check [SSW's Azure consulting page](https://ssw.com.au/consulting/azure). + + \ No newline at end of file diff --git a/rules/bicep-do-you-use-user-defined-data-types/rule.md b/rules/bicep-do-you-use-user-defined-data-types/rule.md new file mode 100644 index 00000000000..6c8e62dc607 --- /dev/null +++ b/rules/bicep-do-you-use-user-defined-data-types/rule.md @@ -0,0 +1,56 @@ +--- +type: rule +archivedreason: +title: Bicep - Do you use User-defined Data Types? +guid: 2a3ba816-ba40-4cfe-8193-7e151e038ac5 +uri: bicep-user-defined-data-types +created: 2024-03-19T19:19:19.1919191Z +authors: +- title: Rick Su + url: https://ssw.com.au/people/rick-su +related: [] +redirects: [] + +--- + +[User-defined data types in Bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/user-defined-data-types) allow you to create custom data structures for better code organization and type safety. They enhance reusability, abstraction, and maintainability within projects . + + + +# Get Started +[Bicep CLI version 0.12.X or higher](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install) is required to use this feature. + +# Pain +When creating a cloud resource, numerous parameters are typically required for configuration and customization. Organizing and naming these parameters effectively is increasingly important. + + +``` bicep +@allowed(['Basic', 'Standard']) +param skuName string = 'Basic' +@allowed([5, 10, 20, 50, 100]) +param skuCapacity int = 5 +param skuSizeInGB int = 2 +``` +:::bad +Bad example - Relying on parameter prefixes and order leads to unclear code, high complexity, and increased maintenance effort. +::: + +``` bicep +// User-defined data type +type skuConfig = { + name: 'Basic' | 'Standard' + capacity: 5 | 10 | 20 | 50 | 100 + sizeInGB: int +} + +param sku skuConfig = { + name: 'Basic' + capacity: 5 + sizeInGB: 2 +} +``` +:::good +Good example - User-defined data type provides type safety, enhanced readability and making maintenance easier. +::: + + From 77cd47ab8414171cfdadfe1e057bb5a16bba292f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Mar 2024 07:12:12 +0000 Subject: [PATCH 2/9] Auto-fix Markdown files --- rules/bicep-do-you-use-user-defined-data-types/rule.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rules/bicep-do-you-use-user-defined-data-types/rule.md b/rules/bicep-do-you-use-user-defined-data-types/rule.md index 6c8e62dc607..61d8b2dc92e 100644 --- a/rules/bicep-do-you-use-user-defined-data-types/rule.md +++ b/rules/bicep-do-you-use-user-defined-data-types/rule.md @@ -18,11 +18,12 @@ redirects: [] # Get Started + [Bicep CLI version 0.12.X or higher](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install) is required to use this feature. # Pain -When creating a cloud resource, numerous parameters are typically required for configuration and customization. Organizing and naming these parameters effectively is increasingly important. +When creating a cloud resource, numerous parameters are typically required for configuration and customization. Organizing and naming these parameters effectively is increasingly important. ``` bicep @allowed(['Basic', 'Standard']) @@ -31,6 +32,7 @@ param skuName string = 'Basic' param skuCapacity int = 5 param skuSizeInGB int = 2 ``` + :::bad Bad example - Relying on parameter prefixes and order leads to unclear code, high complexity, and increased maintenance effort. ::: @@ -49,8 +51,7 @@ param sku skuConfig = { sizeInGB: 2 } ``` + :::good Good example - User-defined data type provides type safety, enhanced readability and making maintenance easier. ::: - - From f5f033d3126670b6d41d44935fdd9acc419a721b Mon Sep 17 00:00:00 2001 From: Rick Su Date: Tue, 19 Mar 2024 18:18:54 +1100 Subject: [PATCH 3/9] Fix headings according to markdown suggestions --- rules/bicep-do-you-use-user-defined-data-types/rule.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/bicep-do-you-use-user-defined-data-types/rule.md b/rules/bicep-do-you-use-user-defined-data-types/rule.md index 61d8b2dc92e..0b2eedf9df1 100644 --- a/rules/bicep-do-you-use-user-defined-data-types/rule.md +++ b/rules/bicep-do-you-use-user-defined-data-types/rule.md @@ -17,11 +17,11 @@ redirects: [] -# Get Started +## Get Started [Bicep CLI version 0.12.X or higher](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install) is required to use this feature. -# Pain +## Pain When creating a cloud resource, numerous parameters are typically required for configuration and customization. Organizing and naming these parameters effectively is increasingly important. From cc694af810174de8cd17041e9d95839e79948635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Ara=C3=BAjo=20=5BSSW=5D?= Date: Tue, 19 Mar 2024 18:22:28 -0300 Subject: [PATCH 4/9] improved punctuations --- rules/bicep-do-you-use-user-defined-data-types/rule.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rules/bicep-do-you-use-user-defined-data-types/rule.md b/rules/bicep-do-you-use-user-defined-data-types/rule.md index 0b2eedf9df1..486573978e9 100644 --- a/rules/bicep-do-you-use-user-defined-data-types/rule.md +++ b/rules/bicep-do-you-use-user-defined-data-types/rule.md @@ -13,7 +13,7 @@ redirects: [] --- -[User-defined data types in Bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/user-defined-data-types) allow you to create custom data structures for better code organization and type safety. They enhance reusability, abstraction, and maintainability within projects . +[User-defined data types in Bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/user-defined-data-types) allow you to create custom data structures for better code organization and type safety. They enhance reusability, abstraction, and maintainability within projects. @@ -34,7 +34,7 @@ param skuSizeInGB int = 2 ``` :::bad -Bad example - Relying on parameter prefixes and order leads to unclear code, high complexity, and increased maintenance effort. +Bad example - Relying on parameter prefixes and order leads to unclear code, high complexity, and increased maintenance effort ::: ``` bicep @@ -53,5 +53,5 @@ param sku skuConfig = { ``` :::good -Good example - User-defined data type provides type safety, enhanced readability and making maintenance easier. +Good example - User-defined data type provides type safety, enhanced readability and making maintenance easier ::: From bdd242654a29616d7dba055f2fbca9813343a7f6 Mon Sep 17 00:00:00 2001 From: "Rick Su [SSW]" Date: Tue, 26 Mar 2024 13:40:07 +1100 Subject: [PATCH 5/9] Update rules/bicep-do-you-use-user-defined-data-types/rule.md Co-authored-by: Matt Wicks [SSW] --- rules/bicep-do-you-use-user-defined-data-types/rule.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rules/bicep-do-you-use-user-defined-data-types/rule.md b/rules/bicep-do-you-use-user-defined-data-types/rule.md index 486573978e9..d6af3a12488 100644 --- a/rules/bicep-do-you-use-user-defined-data-types/rule.md +++ b/rules/bicep-do-you-use-user-defined-data-types/rule.md @@ -17,11 +17,6 @@ redirects: [] -## Get Started - -[Bicep CLI version 0.12.X or higher](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install) is required to use this feature. - -## Pain When creating a cloud resource, numerous parameters are typically required for configuration and customization. Organizing and naming these parameters effectively is increasingly important. From c3dbc419c9b45c230eb6519da54d2a701701badd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 26 Mar 2024 02:40:59 +0000 Subject: [PATCH 6/9] Auto-fix Markdown files --- rules/bicep-do-you-use-user-defined-data-types/rule.md | 1 - 1 file changed, 1 deletion(-) diff --git a/rules/bicep-do-you-use-user-defined-data-types/rule.md b/rules/bicep-do-you-use-user-defined-data-types/rule.md index d6af3a12488..9d806a0941d 100644 --- a/rules/bicep-do-you-use-user-defined-data-types/rule.md +++ b/rules/bicep-do-you-use-user-defined-data-types/rule.md @@ -17,7 +17,6 @@ redirects: [] - When creating a cloud resource, numerous parameters are typically required for configuration and customization. Organizing and naming these parameters effectively is increasingly important. ``` bicep From f0768576a690280e15c91a5f8f395953dbab3b1b Mon Sep 17 00:00:00 2001 From: Rick Su Date: Tue, 26 Mar 2024 17:48:20 +1100 Subject: [PATCH 7/9] Add more bad example --- rules/bicep-do-you-use-user-defined-data-types/rule.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rules/bicep-do-you-use-user-defined-data-types/rule.md b/rules/bicep-do-you-use-user-defined-data-types/rule.md index 9d806a0941d..50294c329b1 100644 --- a/rules/bicep-do-you-use-user-defined-data-types/rule.md +++ b/rules/bicep-do-you-use-user-defined-data-types/rule.md @@ -31,6 +31,14 @@ param skuSizeInGB int = 2 Bad example - Relying on parameter prefixes and order leads to unclear code, high complexity, and increased maintenance effort ::: +``` bicep +param sku object +``` + +:::bad +Bad example - When declaring a parameter as an untyped object, the language cannot validate the object's properties and values at compile time, risking runtime errors. +::: + ``` bicep // User-defined data type type skuConfig = { From d2e79e665c16ffbc8732fb72287392915a6e5a86 Mon Sep 17 00:00:00 2001 From: Rick Su Date: Tue, 26 Mar 2024 17:49:51 +1100 Subject: [PATCH 8/9] change wording --- rules/bicep-do-you-use-user-defined-data-types/rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/bicep-do-you-use-user-defined-data-types/rule.md b/rules/bicep-do-you-use-user-defined-data-types/rule.md index 50294c329b1..c11e9d31abf 100644 --- a/rules/bicep-do-you-use-user-defined-data-types/rule.md +++ b/rules/bicep-do-you-use-user-defined-data-types/rule.md @@ -36,7 +36,7 @@ param sku object ``` :::bad -Bad example - When declaring a parameter as an untyped object, the language cannot validate the object's properties and values at compile time, risking runtime errors. +Bad example - When declaring a parameter as an untyped object, bicep cannot validate the object's properties and values at compile time, risking runtime errors. ::: ``` bicep From 0c5b370cd2df874bef09b3883177336314b2098d Mon Sep 17 00:00:00 2001 From: Rick Su Date: Tue, 26 Mar 2024 17:58:50 +1100 Subject: [PATCH 9/9] Removed IaC category, moved new rule under Azure --- categories/software-engineering/index.md | 1 - .../rules-to-better-azure.md | 3 ++- .../rules-to-better-infrastructure-as-code.md | 17 ----------------- 3 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 categories/software-engineering/rules-to-better-infrastructure-as-code.md diff --git a/categories/software-engineering/index.md b/categories/software-engineering/index.md index f52523b59ce..e2ec8091c32 100644 --- a/categories/software-engineering/index.md +++ b/categories/software-engineering/index.md @@ -7,7 +7,6 @@ index: - rules-to-better-net8-migrations - rules-to-better-architecture-and-code-review - rules-to-better-azure -- rules-to-better-infrastructure-as-code - rules-to-better-blazor - rules-to-better-mvc - rules-to-better-bots diff --git a/categories/software-engineering/rules-to-better-azure.md b/categories/software-engineering/rules-to-better-azure.md index 7b9689a8eee..b7d82188353 100644 --- a/categories/software-engineering/rules-to-better-azure.md +++ b/categories/software-engineering/rules-to-better-azure.md @@ -6,7 +6,7 @@ uri: rules-to-better-azure index: - choose-azure-services - learn-azure -- azure-certifications-and-associated-exams +- azure-certifications-and-associated-exams - the-9-important-parts-of-azure - cloud-architect - azure-architecture-center @@ -15,6 +15,7 @@ index: - do-you-always-rename-staging-url-on-azure - do-you-consider-azuresearch-for-your-website - azure-resources-creating +- bicep-user-defined-data-types - azure-naming-resources - azure-naming-resource-groups - apply-tags-to-your-azure-resource-groups diff --git a/categories/software-engineering/rules-to-better-infrastructure-as-code.md b/categories/software-engineering/rules-to-better-infrastructure-as-code.md deleted file mode 100644 index 7ef0d54d779..00000000000 --- a/categories/software-engineering/rules-to-better-infrastructure-as-code.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -type: category -title: Rules to Better Infrastructure as Code (IaC) -guid: 2948bfca-605b-4e67-974a-3cec1c7aa741 -uri: rules-to-better-infrastructure-as-code -experts: https://www.ssw.com.au/people/?skill=bicep -consulting: https://ssw.com.au/consulting/azure -index: -- bicep-user-defined-data-types - ---- - -Infrastructure as code (IaC) uses DevOps methodology and versioning with a descriptive model to define and deploy infrastructure, such as networks, virtual machines, load balancers, and connection topologies. Just as the same source code always generates the same binary, an IaC model generates the same environment every time it deploys. - -Need help with Microsoft Azure? Check [SSW's Azure consulting page](https://ssw.com.au/consulting/azure). - - \ No newline at end of file