无法在服务器防火墙规则中添加我的客户端IP

时间:2020-03-21 14:12:12

标签: azure azure-sql-database firewall

我有两个订阅计划QA-#####和Prod-########。第一个用于QA环境,第二个用于生产环境。在服务器防火墙列表中添加客户端IP之后,我可以在QA-######订阅上连接Azure数据库。

但是我无法在Prod-#########订阅上连接Azure SQL数据库。当我要在服务器防火墙规则中添加客户端IP时,它会显示成功消息,但未在此处列出。

我还在天蓝色的“帮助和支持”部分提交了支持票,但没有回复。

1 个答案:

答案 0 :(得分:0)

有时,Azure门户存在一些问题,这些问题会影响一小部分Azure客户。我的建议是在等待Azure支持修复问题时使用PowerShell添加所需的防火墙规则。

# Connect-AzAccount
# The SubscriptionId in which to create these objects
$SubscriptionId = ''
# Set the resource group name and location for your server
$resourceGroupName = "myResourceGroup-$(Get-Random)"
$location = "westus2"
# Set an admin login and password for your server
$adminSqlLogin = "SqlAdmin"
$password = "ChangeYourAdminPassword1"
# Set server name - the logical server name has to be unique in the system
$serverName = "server-$(Get-Random)"


$startIp = "0.0.0.0"
$endIp = "0.0.0.0"

# Set subscription 
Set-AzContext -SubscriptionId $subscriptionId 

# Create a resource group
$resourceGroup = New-AzResourceGroup -Name $resourceGroupName -Location $location

# Create a server with a system wide unique server name
$server = New-AzSqlServer -ResourceGroupName $resourceGroupName `
    -ServerName $serverName `
    -Location $location `
    -SqlAdministratorCredentials $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $adminSqlLogin, $(ConvertTo-SecureString -String $password -AsPlainText -Force))

# Create a server firewall rule that allows access from the specified IP range
$serverFirewallRule = New-AzSqlServerFirewallRule -ResourceGroupName $resourceGroupName `
    -ServerName $serverName `
    -FirewallRuleName "AllowedIPs" -StartIpAddress $startIp -EndIpAddress $endIp
相关问题