Skip to content

Commit 5c5ba94

Browse files
authored
Added support for creating and setting Template Spec in Bicep file (#15397)
* Added support for creating and setting Template Spec in Bicep file * polish per comments
1 parent 57c03f2 commit 5c5ba94

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

src/Resources/ResourceManager/Implementation/TemplateSpecs/NewAzTemplateSpec.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1616
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
1717
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
18+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
1819
using Microsoft.Azure.Commands.ResourceManager.Common;
1920
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
2021
using Microsoft.Azure.Management.ResourceManager.Models;
@@ -119,7 +120,7 @@ public class NewAzTemplateSpec : TemplateSpecCmdletBase
119120
ParameterSetName = FromJsonFileParameterSet,
120121
Mandatory = true,
121122
ValueFromPipelineByPropertyName = true,
122-
HelpMessage = "The file path to the local Azure Resource Manager template JSON file.")]
123+
HelpMessage = "The file path to the local Azure Resource Manager template JSON/Bicep file.")]
123124
[ValidateNotNullOrEmpty]
124125
public string TemplateFile { get; set; }
125126

@@ -163,6 +164,11 @@ public override void ExecuteCmdlet()
163164
);
164165
}
165166

167+
if (BicepUtility.IsBicepFile(TemplateFile))
168+
{
169+
filePath = BicepUtility.BuildFile(this.ResolvePath(TemplateFile), this.WriteVerbose);
170+
}
171+
166172
packagedTemplate = TemplateSpecPackagingEngine.Pack(filePath);
167173
break;
168174
case FromJsonStringParameterSet:

src/Resources/ResourceManager/Implementation/TemplateSpecs/SetAzTemplateSpec.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1616
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
1717
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
18+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
1819
using Microsoft.Azure.Commands.ResourceManager.Common;
1920
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
2021
using Microsoft.Azure.Management.ResourceManager.Models;
@@ -138,9 +139,9 @@ public class SetAzTemplateSpec : TemplateSpecCmdletBase
138139

139140
[Alias("InputFile")]
140141
[Parameter(Mandatory = true, ParameterSetName = UpdateVersionByNameFromJsonFileParameterSet, ValueFromPipelineByPropertyName = true,
141-
HelpMessage = "The file path to the local Azure Resource Manager template JSON file.")]
142+
HelpMessage = "The file path to the local Azure Resource Manager template JSON/Bicep file.")]
142143
[Parameter(Mandatory = true, ParameterSetName = UpdateVersionByIdFromJsonFileParameterSet, ValueFromPipelineByPropertyName = true,
143-
HelpMessage = "The file path to the local Azure Resource Manager template JSON file.")]
144+
HelpMessage = "The file path to the local Azure Resource Manager template JSON/Bicep file.")]
144145
[ValidateNotNullOrEmpty]
145146
public string TemplateFile { get; set; }
146147

@@ -201,7 +202,10 @@ public override void ExecuteCmdlet()
201202
string.Format(ProjectResources.InvalidFilePath, TemplateFile)
202203
);
203204
}
204-
205+
if (BicepUtility.IsBicepFile(TemplateFile))
206+
{
207+
filePath = BicepUtility.BuildFile(this.ResolvePath(TemplateFile), this.WriteVerbose);
208+
}
205209
packagedTemplate = TemplateSpecPackagingEngine.Pack(filePath);
206210
break;
207211
case UpdateVersionByIdFromJsonParameterSet:

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Added support for creating and updating Template Spec in Bicep file [#15313]
2223

2324
## Version 4.2.0
2425
* Allowed naming the deployment when testing deployments [#11497]

src/Resources/Resources/help/New-AzTemplateSpec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ New-AzTemplateSpec [-ResourceGroupName] <String> [-Name] <String> -Version <Stri
3030

3131
## DESCRIPTION
3232
Creates a new Template Spec version with the specified ARM Template content. The content can either come from a raw
33-
JSON string (using **FromJsonStringParameterSet** parameter set) or from a specified JSON file
33+
JSON string (using **FromJsonStringParameterSet** parameter set) or from a specified JSON/Bicep file
3434
(using **FromJsonFileParameterSet** parameter set).
3535

3636
If the root Template Spec does not already exist it will be created along with the Template Spec version. If
@@ -189,7 +189,7 @@ Accept wildcard characters: False
189189
```
190190
191191
### -TemplateFile
192-
The file path to the local Azure Resource Manager template JSON file.
192+
The file path to the local Azure Resource Manager template JSON/Bicep file.
193193
194194
```yaml
195195
Type: System.String

src/Resources/Resources/help/Set-AzTemplateSpec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Modifies a Templace Spec. If the Template Spec with the specified name and/or sp
7171
created.
7272

7373
When modifying a Template Spec version's ARM Template content, the content can either come from a raw
74-
JSON string (using **UpdateVersionByNameFromJsonParameterSet** parameter set) or from a specified JSON file
74+
JSON string (using **UpdateVersionByNameFromJsonParameterSet** parameter set) or from a specified JSON/Bicep file
7575
(using **UpdateVersionByNameFromJsonFileParameterSet** parameter set).
7676

7777
## EXAMPLES
@@ -245,7 +245,7 @@ Accept wildcard characters: False
245245
```
246246
247247
### -TemplateFile
248-
The file path to the local Azure Resource Manager template JSON file.
248+
The file path to the local Azure Resource Manager template JSON/Bicep file.
249249
250250
```yaml
251251
Type: System.String

0 commit comments

Comments
 (0)