根据错误提示,问题出在 NSG 安全规则类型转换上。可以通过以下代码示例解决:
在 C# 中:
// 从 JSON 转换 NSG 安全规则
JsonConvert.DeserializeObject
// SecurityRule 类型定义 public class SecurityRule { public string name { get; set; } public int priority { get; set; } public string direction { get; set; } public string access { get; set; } public string protocol { get; set; } public string sourcePortRange { get; set; } public string sourceAddressPrefix { get; set; } public string destinationPortRange { get; set; } public string destinationAddressPrefix { get; set; } }
在 PowerShell 中:
$securityRule = ConvertFrom-Json $json -AsHashtable
@{ name = "" priority = 0 direction = "" access = "" protocol = "" sourcePortRange = "" sourceAddressPrefix = "" destinationPortRange = "" destinationAddressPrefix = "" }
上一篇:Azure管道:当“condition:succeeded()”位于参数中时,传递参数到模板不起作用。
下一篇:Azure函数5和EFCore5出现“无法加载文件或程序集Microsoft.Extensions.DependencyInjection.Abstractions”的错误。