Azure MySql Rest API。插入新的防火墙规则

Azure MySql Rest API。插入新的防火墙规则,mysql,rest,api,azure,firewall,Mysql,Rest,Api,Azure,Firewall,我正在尝试创建新的防火墙规则。更新现有规则没有问题,但无法创建新规则。我得到了真实的状态码响应,但在Azure门户中看不到结果(几分钟后)。附加的代码属于一个Web应用程序,该应用程序具有MySql组资源的专有角色。我做错了什么 private static string URI_FIREWALL_BASE = "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/MY_RESOURCE/prov

我正在尝试创建新的防火墙规则。更新现有规则没有问题,但无法创建新规则。我得到了真实的状态码响应,但在Azure门户中看不到结果(几分钟后)。附加的代码属于一个Web应用程序,该应用程序具有MySql组资源的专有角色。我做错了什么

private static string URI_FIREWALL_BASE = "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/MY_RESOURCE/providers/Microsoft.DBforMySQL/servers/MYSERVER/firewallRules/";

public string AddIPFirewallRule(string email, string IP)
    {
        AuthenticationResult token = AsyncContext.Run(() => AzureActiveDirectory.GetS2SAccessTokenForProdMSAAsync());
        HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);

        JObject NewRule =
            new JObject(
            new JProperty("properties",
                new JObject(
                    new JProperty("startIpAddress", IP),
                    new JProperty("endIpAddress", IP)
                    )));

        var content = JsonConvert.SerializeObject(NewRule);
        var httpContent = new StringContent(content, Encoding.UTF8, "application/json"); 

        HttpResponseMessage resp = AsyncContext.Run(() => client.PutAsync(URI_FIREWALL_BASE + $"{email}?api-version=2017-12-01", httpContent));
        return AsyncContext.Run(() => resp.Content.ReadAsStringAsync());
    }

我终于明白了。我必须遵循一些规则来命名新服务,正如您可以在Azure Portal Desktop上看到的那样。我终于找到了它。我必须遵循一些规则来命名新服务,正如您可以在Azure Portal Desktop上看到的那样。您可以将您的评论作为答案发布,以帮助其他人查找,谢谢。Azure DB for MySQL防火墙规则的REST API文档可在此处获得: