|
12 | 12 | // limitations under the License.
|
13 | 13 | // ----------------------------------------------------------------------------------
|
14 | 14 |
|
15 |
| -using System; |
16 |
| -using System.Collections; |
17 |
| -using System.Collections.Generic; |
18 |
| -using System.Linq; |
19 |
| -using System.Management.Automation; |
20 |
| -using System.Net; |
21 | 15 | using Microsoft.Azure.Commands.Common.Authentication;
|
22 | 16 | using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
|
23 | 17 | using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
|
24 | 18 | using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
|
25 | 19 | using Microsoft.Azure.Management.ResourceManager;
|
26 | 20 | using Microsoft.Azure.Management.ResourceManager.Models;
|
27 | 21 | using Microsoft.WindowsAzure.Commands.Utilities.Common;
|
| 22 | + |
28 | 23 | using Newtonsoft.Json.Linq;
|
29 | 24 |
|
| 25 | +using System; |
| 26 | +using System.Collections; |
| 27 | +using System.Collections.Generic; |
| 28 | +using System.Linq; |
| 29 | +using System.Management.Automation; |
| 30 | +using System.Net; |
| 31 | + |
30 | 32 | namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
|
31 | 33 | {
|
32 | 34 | public abstract class ResourceWithParameterCmdletBase : ResourceManagerCmdletBase
|
@@ -115,24 +117,24 @@ protected ResourceWithParameterCmdletBase()
|
115 | 117 | public Hashtable TemplateObject { get; set; }
|
116 | 118 |
|
117 | 119 | [Parameter(ParameterSetName = TemplateFileParameterObjectParameterSetName,
|
118 |
| - Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Local path to the template file.")] |
| 120 | + Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Local path to the template file. Supported template file type: json and bicep.")] |
119 | 121 | [Parameter(ParameterSetName = TemplateFileParameterFileParameterSetName,
|
120 |
| - Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Local path to the template file.")] |
| 122 | + Mandatory = true, ValueFromPipelineByPropertyName = true)] |
121 | 123 | [Parameter(ParameterSetName = TemplateFileParameterUriParameterSetName,
|
122 |
| - Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Local path to the template file.")] |
| 124 | + Mandatory = true, ValueFromPipelineByPropertyName = true)] |
123 | 125 | [Parameter(ParameterSetName = ParameterlessTemplateFileParameterSetName,
|
124 |
| - Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Local path to the template file.")] |
| 126 | + Mandatory = true, ValueFromPipelineByPropertyName = true)] |
125 | 127 | [ValidateNotNullOrEmpty]
|
126 | 128 | public string TemplateFile { get; set; }
|
127 | 129 |
|
128 | 130 | [Parameter(ParameterSetName = TemplateUriParameterObjectParameterSetName,
|
129 | 131 | Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Uri to the template file.")]
|
130 | 132 | [Parameter(ParameterSetName = TemplateUriParameterFileParameterSetName,
|
131 |
| - Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Uri to the template file.")] |
| 133 | + Mandatory = true, ValueFromPipelineByPropertyName = true)] |
132 | 134 | [Parameter(ParameterSetName = TemplateUriParameterUriParameterSetName,
|
133 |
| - Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Uri to the template file.")] |
| 135 | + Mandatory = true, ValueFromPipelineByPropertyName = true)] |
134 | 136 | [Parameter(ParameterSetName = ParameterlessTemplateUriParameterSetName,
|
135 |
| - Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Uri to the template file.")] |
| 137 | + Mandatory = true, ValueFromPipelineByPropertyName = true)] |
136 | 138 | [ValidateNotNullOrEmpty]
|
137 | 139 | public string TemplateUri { get; set; }
|
138 | 140 |
|
@@ -177,6 +179,9 @@ public ITemplateSpecsClient TemplateSpecsClient
|
177 | 179 |
|
178 | 180 | public virtual object GetDynamicParameters()
|
179 | 181 | {
|
| 182 | + if (BicepUtility.IsBicepFile(TemplateFile)) |
| 183 | + BuildAndUseBicepTemplate(); |
| 184 | + |
180 | 185 | if (!this.IsParameterBound(c => c.SkipTemplateParameterPrompt))
|
181 | 186 | {
|
182 | 187 | // Resolve the static parameter names for this cmdlet:
|
@@ -428,5 +433,10 @@ protected string[] GetStaticParameterNames()
|
428 | 433 | CmdletInfo cmdletInfo = new CmdletInfo(commandName, this.GetType());
|
429 | 434 | return cmdletInfo.Parameters.Keys.ToArray();
|
430 | 435 | }
|
| 436 | + |
| 437 | + protected void BuildAndUseBicepTemplate() |
| 438 | + { |
| 439 | + TemplateFile = BicepUtility.BuildFile(this.ExecuteScript<Object>, this.ResolvePath(TemplateFile)); |
| 440 | + } |
431 | 441 | }
|
432 | 442 | }
|
0 commit comments