gpt4 book ai didi

azure - 如何使用 C# 将 AppSettings.json 转换为高级 Azure 设置?

转载 作者:行者123 更新时间:2023-12-02 23:01:31 25 4
gpt4 key购买 nike

您是否注意到 Azure 升级了 AppSettings Management?现在可以使用高级编辑选项一次性更新多个 AppSettings,但格式与 AppSettings.json 不同。

Azure Edit Options

我正在寻找一种快速解决方案,将我的 AppSettings 部分转换为 Azure 高级编辑选项格式。你知道该怎么做吗?

所以这个:

"Simulation": {
"ApiUrl": "YourApiUrl",
"ApiKey": "YouApiKey",
"Groups": [
{
"Name": "YourGroup",
"Latitude": 45.50884,
"Longitude": -73.58781,
"Radius": 500
}
],
"Planifications": [
{
"GroupName": "YourGroup",
"At": "07:00",
"Status": 10
}
]
}

将被格式化为:

[
{
"Name": "Simulation:ApiUrl",
"Value": "YourApiUrl",
"SlotSetting": false
},
{
"Name": "Simulation:ApiKey",
"Value": "YourApiKey",
"SlotSetting": false
},
{
"Name": "Simulation:Groups:0:Name",
"Value": "YourGroup",
"SlotSetting": false
},
{
"Name": "Simulation:Groups:0:Latitude",
"Value": "45.50884",
"SlotSetting": false
},
{
"Name": "Simulation:Groups:0:Longitude",
"Value": "-73.58781",
"SlotSetting": false
},
{
"Name": "Simulation:Groups:0:Radius",
"Value": "500",
"SlotSetting": false
},
{
"Name": "Simulation:Planifications:0:GroupName",
"Value": "YourGroup",
"SlotSetting": false
},
{
"Name": "Simulation:Planifications:0:At",
"Value": "07:00:00",
"SlotSetting": false
},
{
"Name": "Simulation:Planifications:0:Status",
"Value": "10",
"SlotSetting": false
}
]

最佳答案

Nuget 上有一个 dotnet 工具可以进行转换 dotnet-appsettings 。需要 .NET 3.1 SDK。

dotnet tool install --global dotnet-appsettings
dotnet tool list --global
Usage: appsettings [appsettings.json]

关于azure - 如何使用 C# 将 AppSettings.json 转换为高级 Azure 设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57315514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com