Skip to content

Commit 5230a92

Browse files
committed
registry info and rename to snake-case for bicep files
1 parent 8cafd79 commit 5230a92

10 files changed

+70
-10
lines changed

README.md

+35-4
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,39 @@ To compile, make sure to install [PowerShell Az](https://www.powershellgallery.c
3131
- param `location`, a location (a valid Azure region), for instance `westeurope`;
3232
- param `allowPublicResources`, either `0` or `1`. Sets the public network access property on resources.
3333

34-
```bash
34+
```powershell
3535
Connect-AzAccount
3636
./scripts/Build-Lib.ps1 -location westeurope -allowPublicResources 0
3737
```
3838

39+
## Deploy ##
40+
41+
Ideally, deploy the [/lib/](/lib/) files to an [Azure Container Registry](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-intro) for improved reusability in your project or organization. All types, function and variables can be used.
42+
43+
To deploy, make sure to:
44+
45+
- [compile](#compile) Bicep#;
46+
- provision an Azure Container Registry into your tenant;
47+
- add Bicep to your PATH by [installing manually](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install#install-manually).
48+
49+
Then run with:
50+
51+
- param `acrLoginServer`, the login server of an Azure Container Registry, for instance `acrbicepsharp.azurecr.io`;
52+
- param `versionPostfix`, sets the version of the files to publish, if the version already exists, it will overwrite.
53+
54+
```powershell
55+
Connect-AzAccount
56+
./scripts/Publish-Lib.ps1 -acrLoginServer "acrbicepsharp.azurecr.io" -versionPostfix 1
57+
```
58+
59+
After deployment, you can use any of the public lib files in your own project by referring to the ACR in a Bicep file, for instance like this:
60+
```bash
61+
import * as sharpNetwork from 'br:acrbicepsharp.azurecr.io/bicepsharp/network:v1'
62+
```
63+
3964
## Samples ##
4065

41-
Try out [the samples](/samples/) by running the following commands:
66+
The samples use local files and not from a registry, but give a good idea how to use Bicep#. Try out [the samples](/samples/) by running the following commands:
4267

4368
```bash
4469
az login
@@ -63,6 +88,12 @@ Module oriented libraries like [Azure Verified Modules](https://azure.github.io/
6388

6489
## Technical design ##
6590

91+
### Casing ###
92+
93+
Bicep filenames are snake-case in order to support imports into Azure Container registry.
94+
95+
Bicep variables, functions, types and all other filenames are lowerCamelCase.
96+
6697
### Public facing ###
6798

6899
The root of [/lib/](/lib/) contains public variables, types and functions to be used by the end-user, smartly grouped together, to;
@@ -82,8 +113,8 @@ Lib files should only have a use case within two scopes at most, and ideally jus
82113
| authorization | [Azure Role Based Access Control](https://learn.microsoft.com/en-us/azure/role-based-access-control/overview) | resourceGroup |
83114
| network | [Azure Networking](https://azure.microsoft.com/en-us/products/category/networking) | resourceGroup |
84115
| storage | Azure Storage | resourceGroup |
85-
| devOpsServices | DevOps Services | bicepparam |
86-
| entraId | Entra ID | bicepparam |
116+
| devops-services | DevOps Services | bicepparam |
117+
| entra-id | Entra ID | bicepparam |
87118

88119
### Breakdown of artifacts in lib files ###
89120

bicepconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
}
1313
},
1414
"experimentalFeaturesEnabled": {
15+
"publishSource": true,
1516
"extensibility": true,
1617
"compileTimeImports": true,
1718
"userDefinedFunctions": true,

lib/devOpsServices.bicep lib/devops-services.bicep

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as _devOpsServices from 'private/variables/devOpsServices.bicep'
1+
import * as _devOpsServices from 'private/variables/devops-services.bicep'
22

33
/* ----------------------------------------
44

lib/entraId.bicep lib/entra-id.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as _entraIdVar from 'private/variables/entraId.bicep'
2-
import * as _entraIdType from 'private/types/entraId.bicep'
1+
import * as _entraIdVar from 'private/variables/entra-id.bicep'
2+
import * as _entraIdType from 'private/types/entra-id.bicep'
33

44
/* ----------------------------------------
55

lib/private/functions/authorization.bicep

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as _authType from '../types/authorization.bicep'
2-
import * as _entraIdType from '../types/entraId.bicep'
2+
import * as _entraIdType from '../types/entra-id.bicep'
33

44
@description('''
55
Get the complete role resource id based of a role id
File renamed without changes.
File renamed without changes.

samples/main.dev.bicepparam

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as sharpTag from '../lib/tag.bicep'
2-
import * as sharpEntraId from '../lib/entraId.bicep'
3-
import * as sharpDevOpsServices from '../lib/devOpsServices.bicep'
2+
import * as sharpEntraId from '../lib/entra-id.bicep'
3+
import * as sharpDevOpsServices from '../lib/devops-services.bicep'
44

55
using 'main.bicep'
66

scripts/Publish-Lib.ps1

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<#
2+
Publish the Bicep# library artifacts to an Azure Container Registry.
3+
4+
Parameters:
5+
- acrLoginServer - The login server of an Azure Container Registry
6+
- versionPostfix - Sets the version of the files to publish, if the version already exists, it will overwrite
7+
8+
#>
9+
[CmdletBinding()]
10+
param (
11+
[Parameter(Mandatory = $true)]
12+
[string] $acrLoginServer,
13+
14+
[Parameter(Mandatory = $false)]
15+
[int] $versionPostfix = 1
16+
)
17+
18+
Write-Output "🤠 😎 💪 Bicep# publisher"
19+
20+
$global:ErrorActionPreference = 'Stop'
21+
22+
$libFiles = Get-ChildItem -Path "./lib/" -File
23+
24+
foreach ($libFile in $libFiles) {
25+
$target = "br:$acrLoginServer/bicepsharp/$($libFile.Basename):v$versionPostfix"
26+
Write-Output "publishing $target..."
27+
Publish-AzBicepModule -FilePath $libFile.FullName -Target $target -DocumentationUri "" -Force
28+
}

0 commit comments

Comments
 (0)