Skip to content

Added support for creating and setting Template Spec in Bicep file #15397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
using Microsoft.Azure.Commands.ResourceManager.Common;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.ResourceManager.Models;
Expand Down Expand Up @@ -119,7 +120,7 @@ public class NewAzTemplateSpec : TemplateSpecCmdletBase
ParameterSetName = FromJsonFileParameterSet,
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The file path to the local Azure Resource Manager template JSON file.")]
HelpMessage = "The file path to the local Azure Resource Manager template JSON/Bicep file.")]
[ValidateNotNullOrEmpty]
public string TemplateFile { get; set; }

Expand Down Expand Up @@ -163,6 +164,11 @@ public override void ExecuteCmdlet()
);
}

if (BicepUtility.IsBicepFile(TemplateFile))
{
filePath = BicepUtility.BuildFile(this.ResolvePath(TemplateFile), this.WriteVerbose);
}

packagedTemplate = TemplateSpecPackagingEngine.Pack(filePath);
break;
case FromJsonStringParameterSet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
using Microsoft.Azure.Commands.ResourceManager.Common;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.ResourceManager.Models;
Expand Down Expand Up @@ -138,9 +139,9 @@ public class SetAzTemplateSpec : TemplateSpecCmdletBase

[Alias("InputFile")]
[Parameter(Mandatory = true, ParameterSetName = UpdateVersionByNameFromJsonFileParameterSet, ValueFromPipelineByPropertyName = true,
HelpMessage = "The file path to the local Azure Resource Manager template JSON file.")]
HelpMessage = "The file path to the local Azure Resource Manager template JSON/Bicep file.")]
[Parameter(Mandatory = true, ParameterSetName = UpdateVersionByIdFromJsonFileParameterSet, ValueFromPipelineByPropertyName = true,
HelpMessage = "The file path to the local Azure Resource Manager template JSON file.")]
HelpMessage = "The file path to the local Azure Resource Manager template JSON/Bicep file.")]
[ValidateNotNullOrEmpty]
public string TemplateFile { get; set; }

Expand Down Expand Up @@ -201,7 +202,10 @@ public override void ExecuteCmdlet()
string.Format(ProjectResources.InvalidFilePath, TemplateFile)
);
}

if (BicepUtility.IsBicepFile(TemplateFile))
{
filePath = BicepUtility.BuildFile(this.ResolvePath(TemplateFile), this.WriteVerbose);
}
packagedTemplate = TemplateSpecPackagingEngine.Pack(filePath);
break;
case UpdateVersionByIdFromJsonParameterSet:
Expand Down
1 change: 1 addition & 0 deletions src/Resources/Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->

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

## Version 4.2.0
* Allowed naming the deployment when testing deployments [#11497]
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Resources/help/New-AzTemplateSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ New-AzTemplateSpec [-ResourceGroupName] <String> [-Name] <String> -Version <Stri

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

If the root Template Spec does not already exist it will be created along with the Template Spec version. If
Expand Down Expand Up @@ -189,7 +189,7 @@ Accept wildcard characters: False
```

### -TemplateFile
The file path to the local Azure Resource Manager template JSON file.
The file path to the local Azure Resource Manager template JSON/Bicep file.

```yaml
Type: System.String
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Resources/help/Set-AzTemplateSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Modifies a Templace Spec. If the Template Spec with the specified name and/or sp
created.

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

## EXAMPLES
Expand Down Expand Up @@ -245,7 +245,7 @@ Accept wildcard characters: False
```

### -TemplateFile
The file path to the local Azure Resource Manager template JSON file.
The file path to the local Azure Resource Manager template JSON/Bicep file.

```yaml
Type: System.String
Expand Down