diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/Azure.CloudMachine.sln b/sdk/provisioning/Azure.Provisioning.CloudMachine/Azure.CloudMachine.sln
index 4a3ca5dfef4e7..3e3ec98764e59 100644
--- a/sdk/provisioning/Azure.Provisioning.CloudMachine/Azure.CloudMachine.sln
+++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/Azure.CloudMachine.sln
@@ -7,6 +7,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.CloudMac
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.CloudMachine.Tests", "tests\Azure.Provisioning.CloudMachine.Tests.csproj", "{46DCEF27-4157-4FB6-A283-B8484EC45665}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning", "..\Azure.Provisioning\src\Azure.Provisioning.csproj", "{2F492C07-8182-41E2-8C68-27D353C9AB74}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.KeyVault", "..\Azure.Provisioning.KeyVault\src\Azure.Provisioning.KeyVault.csproj", "{DA43BF21-558B-438B-9DBF-1A88130C944A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.ServiceBus", "..\Azure.Provisioning.ServiceBus\src\Azure.Provisioning.ServiceBus.csproj", "{48D33345-B5A8-4F94-84D6-A61F8E16271D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.EventGrid", "..\Azure.Provisioning.EventGrid\src\Azure.Provisioning.EventGrid.csproj", "{BCBAF45F-E078-4230-9BDC-4DE9F2FBEE9A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.CognitiveServices", "..\Azure.Provisioning.CognitiveServices\src\Azure.Provisioning.CognitiveServices.csproj", "{987279D2-202C-488A-BA47-37FCEEA51536}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.Storage", "..\Azure.Provisioning.Storage\src\Azure.Provisioning.Storage.csproj", "{813E7228-2B59-41D2-9AFC-BF4092EC7090}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +33,30 @@ Global
{46DCEF27-4157-4FB6-A283-B8484EC45665}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46DCEF27-4157-4FB6-A283-B8484EC45665}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46DCEF27-4157-4FB6-A283-B8484EC45665}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2F492C07-8182-41E2-8C68-27D353C9AB74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2F492C07-8182-41E2-8C68-27D353C9AB74}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2F492C07-8182-41E2-8C68-27D353C9AB74}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2F492C07-8182-41E2-8C68-27D353C9AB74}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DA43BF21-558B-438B-9DBF-1A88130C944A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DA43BF21-558B-438B-9DBF-1A88130C944A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DA43BF21-558B-438B-9DBF-1A88130C944A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DA43BF21-558B-438B-9DBF-1A88130C944A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {48D33345-B5A8-4F94-84D6-A61F8E16271D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {48D33345-B5A8-4F94-84D6-A61F8E16271D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {48D33345-B5A8-4F94-84D6-A61F8E16271D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {48D33345-B5A8-4F94-84D6-A61F8E16271D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BCBAF45F-E078-4230-9BDC-4DE9F2FBEE9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BCBAF45F-E078-4230-9BDC-4DE9F2FBEE9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BCBAF45F-E078-4230-9BDC-4DE9F2FBEE9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BCBAF45F-E078-4230-9BDC-4DE9F2FBEE9A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {987279D2-202C-488A-BA47-37FCEEA51536}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {987279D2-202C-488A-BA47-37FCEEA51536}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {987279D2-202C-488A-BA47-37FCEEA51536}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {987279D2-202C-488A-BA47-37FCEEA51536}.Release|Any CPU.Build.0 = Release|Any CPU
+ {813E7228-2B59-41D2-9AFC-BF4092EC7090}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {813E7228-2B59-41D2-9AFC-BF4092EC7090}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {813E7228-2B59-41D2-9AFC-BF4092EC7090}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {813E7228-2B59-41D2-9AFC-BF4092EC7090}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Azure.Provisioning.CloudMachine.csproj b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Azure.Provisioning.CloudMachine.csproj
index ed107bf9260a1..14e43a27f65b3 100644
--- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Azure.Provisioning.CloudMachine.csproj
+++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Azure.Provisioning.CloudMachine.csproj
@@ -20,10 +20,11 @@
+
+
-
-
+
diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/Azd.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/AzdHelpers.cs
similarity index 84%
rename from sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/Azd.cs
rename to sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/AzdHelpers.cs
index 0e910d262d9f9..f2907aaceb68c 100644
--- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/Azd.cs
+++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/AzdHelpers.cs
@@ -13,7 +13,7 @@
namespace Azure.CloudMachine;
-internal static class Azd
+internal static class AzdHelpers
{
private const string MainBicepName = "main";
private const string ResourceGroupVersion = "2024-03-01";
@@ -115,18 +115,29 @@ internal static string ReadOrCreateCmid()
return cmid;
}
else
- { // add CM configuration to existing file
- JsonNode? root = JsonValue.Parse(appsettings);
- if (root is null)
- throw new NotImplementedException();
-
- if (root is not JsonObject obj)
- throw new NotImplementedException();
+ { // add CM configuration to existing file
+ json.Seek(0, SeekOrigin.Begin);
+ JsonNode? root = JsonNode.Parse(json);
+ json.Close();
+ if (root is null || root is not JsonObject obj) throw new InvalidOperationException("Existing appsettings.json is not a valid JSON object");
var cmProperties = new JsonObject();
cmid = GenerateCloudMachineId();
cmProperties.Add("ID", cmid);
obj.Add("CloudMachine", cmProperties);
+
+ using FileStream file = File.OpenWrite(appsettings);
+ JsonWriterOptions writerOptions = new()
+ {
+ Indented = true,
+ };
+ Utf8JsonWriter writer = new(file, writerOptions);
+ JsonSerializerOptions options = new()
+ {
+ WriteIndented = true,
+ };
+ root.WriteTo(writer, options);
+ writer.Flush();
}
return cmid;
diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/CloudMachineInfrastructure.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/CloudMachineInfrastructure.cs
index ae88d693a55ec..4576781586700 100644
--- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/CloudMachineInfrastructure.cs
+++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/CloudMachineInfrastructure.cs
@@ -277,7 +277,7 @@ public static bool Configure(string[] args, Action?
return false;
}
- string cmid = Azd.ReadOrCreateCmid();
+ string cmid = AzdHelpers.ReadOrCreateCmid();
CloudMachineInfrastructure cmi = new(cmid);
if (configure != default)
@@ -286,7 +286,7 @@ public static bool Configure(string[] args, Action?
}
string infraDirectory = Path.Combine(".", "infra");
- Azd.Init(infraDirectory, cmi);
+ AzdHelpers.Init(infraDirectory, cmi);
return true;
}
}
diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineWorkspace.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineWorkspace.cs
index 89eb5b8b93e97..c4505a5f5ca56 100644
--- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineWorkspace.cs
+++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineWorkspace.cs
@@ -32,7 +32,7 @@ public CloudMachineWorkspace(TokenCredential? credential = default, IConfigurati
string? cmid;
if (configuration == default)
{
- cmid = Azd.ReadOrCreateCmid();
+ cmid = AzdHelpers.ReadOrCreateCmid();
}
else
{