Skip to content

Commit 0cef1cf

Browse files
authored
[Resources] Update Publish-AzBicepModule to include new optional parameter -DocumentationUri (#21122)
* Added new -Documentationuri for bicep publish command * Updated ChangeLog.md * Updated changelog
1 parent b8de959 commit 0cef1cf

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

src/Resources/ResourceManager/Implementation/Bicep/PublishAzureBicepModuleCmdlet.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ public class PublishAzureBicepModuleCmdlet : AzureRMCmdlet
3030
[ValidateNotNullOrEmpty]
3131
public string Target { get; set; }
3232

33+
[Parameter(Mandatory = false, HelpMessage = "Documentation uri of the Bicep module.")]
34+
public string DocumentationUri { get; set; }
35+
3336
[Parameter(Mandatory = false, HelpMessage="Indicates that this cmdlet returns a boolean result. By default, this cmdlet does not generate any output.")]
3437
public SwitchParameter PassThru { get; set; }
3538

3639
public override void ExecuteCmdlet()
3740
{
38-
BicepUtility.PublishFile(this.TryResolvePath(this.FilePath), this.Target, this.WriteVerbose, this.WriteWarning);
41+
BicepUtility.PublishFile(this.TryResolvePath(this.FilePath), this.Target, this.DocumentationUri, this.WriteVerbose, this.WriteWarning);
3942

4043
if (this.PassThru.IsPresent)
4144
{

src/Resources/ResourceManager/Utilities/BicepUtility.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ internal static class BicepUtility
3030

3131
private const string MinimalVersionRequirementForBicepPublish = "0.4.1008";
3232

33+
private const string MinimalVersionRequirementForBicepPublishWithOptionalDocumentationUriParameter = "0.14.46";
34+
3335
public delegate void OutputCallback(string msg);
3436

3537
public static bool IsBicepFile(string templateFilePath) =>
@@ -56,14 +58,26 @@ public static string BuildFile(string bicepTemplateFilePath, OutputCallback writ
5658
return buildResultPath;
5759
}
5860

59-
public static void PublishFile(string bicepFilePath, string target, OutputCallback writeVerbose = null, OutputCallback writeWarning = null)
61+
public static void PublishFile(string bicepFilePath, string target, string documentationUri = null, OutputCallback writeVerbose = null, OutputCallback writeWarning = null)
6062
{
6163
if (!FileUtilities.DataStore.FileExists(bicepFilePath))
6264
{
6365
throw new AzPSArgumentException(Properties.Resources.InvalidBicepFilePath, "File");
6466
}
6567

66-
RunBicepCommand($"bicep publish '{bicepFilePath}' --target '{target}'", MinimalVersionRequirementForBicepPublish, writeVerbose, writeWarning);
68+
string bicepPublishCommand;
69+
70+
if (!string.IsNullOrWhiteSpace(documentationUri))
71+
{
72+
CheckMinimalVersionRequirement(MinimalVersionRequirementForBicepPublishWithOptionalDocumentationUriParameter);
73+
bicepPublishCommand = $"bicep publish '{bicepFilePath}' --target '{target}' --documentationUri '{documentationUri}'";
74+
}
75+
else
76+
{
77+
bicepPublishCommand = $"bicep publish '{bicepFilePath}' --target '{target}'";
78+
}
79+
80+
RunBicepCommand(bicepPublishCommand, MinimalVersionRequirementForBicepPublish, writeVerbose, writeWarning);
6781
}
6882

6983
private static void CheckBicepExecutable()

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
## Version 6.5.3
2525
* Updated behavior of Get-AzPolicyDefinition which previously returned all definitions when -Id was provided with a nonexistent policy definition id. Fixed to correctly throw a 404 exception in this case.
26+
* Updated `Publish-AzBicepModule` to include new optional parameter `-DocumentationUri`
2627

2728
## Version 6.5.2
2829
* Fixed query issue when objectId in assignment is empty for `Get-DenyAssignment`

src/Resources/Resources/help/Publish-AzBicepModule.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Publishes a Bicep file to a registry.
1313
## SYNTAX
1414

1515
```
16-
Publish-AzBicepModule -FilePath <String> -Target <String> [-PassThru]
16+
Publish-AzBicepModule -FilePath <String> -Target <String> -DocumentationUri <String> [-PassThru]
1717
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
1818
```
1919

@@ -91,6 +91,21 @@ Accept pipeline input: True (ByPropertyName)
9191
Accept wildcard characters: False
9292
```
9393
94+
### -DocumentationUri
95+
The documentation uri of the Bicep module..
96+
97+
```yaml
98+
Type: System.String
99+
Parameter Sets: (All)
100+
Aliases:
101+
102+
Required: False
103+
Position: Named
104+
Default value: None
105+
Accept pipeline input: True (ByPropertyName)
106+
Accept wildcard characters: False
107+
```
108+
94109
### -Confirm
95110
Prompts you for confirmation before running the cmdlet.
96111

0 commit comments

Comments
 (0)