PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}?api-version=2023-08-01
URI 参数
名称
在
必需
类型
说明
firewallRuleName
path
True
string
防火墙规则的名称。
resourceGroupName
path
True
string
包含资源的资源组的名称。 可以从 Azure 资源管理器 API 或门户获取此值。
serverName
path
True
string
服务器的名称。
subscriptionId
path
True
string
标识 Azure 订阅的订阅 ID。
api-version
query
True
string
要用于请求的 API 版本。
请求正文
名称
类型
说明
name
string
资源名称。
properties.endIpAddress
string
防火墙规则的结束 IP 地址。 必须是 IPv4 格式。 必须大于或等于 startIpAddress。 对所有 Azure 内部 IP 地址使用值“0.0.0.0”。
properties.startIpAddress
string
防火墙规则的起始 IP 地址。 必须是 IPv4 格式。 对所有 Azure 内部 IP 地址使用值“0.0.0.0”。
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2023-08-01/examples/FirewallRuleCreate.json
// this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "firewallrulecrudtest-12";
string serverName = "firewallrulecrudtest-6285";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlFirewallRuleResource
SqlFirewallRuleCollection collection = sqlServer.GetSqlFirewallRules();
// invoke the operation
string firewallRuleName = "firewallrulecrudtest-5370";
SqlFirewallRuleData data = new SqlFirewallRuleData
{
StartIPAddress = "0.0.0.3",
EndIPAddress = "0.0.0.3",
};
ArmOperation<SqlFirewallRuleResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data);
SqlFirewallRuleResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SqlFirewallRuleData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2023-08-01/examples/FirewallRuleUpdate.json
// this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "firewallrulecrudtest-12";
string serverName = "firewallrulecrudtest-6285";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlFirewallRuleResource
SqlFirewallRuleCollection collection = sqlServer.GetSqlFirewallRules();
// invoke the operation
string firewallRuleName = "firewallrulecrudtest-3927";
SqlFirewallRuleData data = new SqlFirewallRuleData
{
StartIPAddress = "0.0.0.1",
EndIPAddress = "0.0.0.1",
};
ArmOperation<SqlFirewallRuleResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data);
SqlFirewallRuleResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SqlFirewallRuleData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");