Skip to content

Commit de48b2b

Browse files
committed
changes
1 parent 5b730f5 commit de48b2b

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/Resources/ResourceManager/Implementation/ResourceGroups/ExportAzureResourceGroupCmdlet.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ protected override void OnProcessRecord()
185185
}
186186
}
187187

188+
// Determine the correct file extension based on OutputFormat
189+
string extension = OutputFormat.Equals(ExportTemplateOutputFormat.Bicep, StringComparison.OrdinalIgnoreCase) ? ".bicep" : ".json";
190+
188191
string path = FileUtility.SaveTemplateFile(
189192
templateName: this.ResourceGroupName,
190193
contents: contents,
@@ -193,7 +196,9 @@ protected override void OnProcessRecord()
193196
? System.IO.Path.Combine(CurrentPath(), this.ResourceGroupName)
194197
: this.TryResolvePath(this.Path),
195198
overwrite: Force.IsPresent,
196-
shouldContinue: ShouldContinue);
199+
shouldContinue: ShouldContinue,
200+
extension: extension // Pass the extension
201+
);
197202

198203
WriteObject(PowerShellUtilities.ConstructPSObject(null, "Path", path));
199204
}

src/Resources/ResourceManager/Utilities/FileUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static class FileUtility
3636
/// <param name="overwrite">Overrides existing file</param>
3737
/// <param name="shouldContinue">The confirmation action</param>
3838
/// <returns>The file path</returns>
39-
public static string SaveTemplateFile(string templateName, string contents, string outputPath, bool overwrite, Func<string, string, bool> shouldContinue)
39+
public static string SaveTemplateFile(string templateName, string contents, string outputPath, bool overwrite, Func<string, string, bool> shouldContinue, string extension = ".json") // Added extension parameter with default
4040
{
4141
StringBuilder finalOutputPath = new StringBuilder();
4242

src/Resources/Resources.Test/ScenarioTests/ResourceGroupTests.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ function Test-ExportResourceGroupBicep
421421
Clean-ResourceGroup $rgname
422422
}
423423
}
424-
}
425424

426425

427426
<#

0 commit comments

Comments
 (0)