Azure SQL Firewall

RJ 366 Reputation points
2025-08-07T12:47:55.9166667+00:00

Hi there,

I have 2 environments. I'm more of admin on Azure environment (recently made as subscription admin) after which Dev issue - Azure SQL I'm having difficulty to remove IP from Azure SQL Firewall. (Earlier i was able to) today my manager granted me subscription admin and as SQL Security Manager and it still not able to remove grayed out IPs. 

Azure SQL Database
{count} votes

2 answers

Sort by: Most helpful
  1. Alberto Morillo 35,406 Reputation points MVP Volunteer Moderator
    2025-08-07T22:52:46.9066667+00:00

    To my knowledge, you need "Contributor" or "Owner" on the logical server resource.

    About the error with sp_delete_firewall_rule, it should be executed on master database for server-level rules. The rules you are trying to change have been defined on logical server.


  2. Kalyani Kondavaradala 4,600 Reputation points Microsoft External Staff Moderator
    2025-08-08T09:58:04.94+00:00

    Hello @RJ,

    Thanks for reaching out on Microsoft Q&A! let me try to help with some steps

    Why You Can't Delete Grayed-Out Ips:

    Even though you have roles like SQL Security Manager and Subscription Admin, those roles do not give you permission to manage server-level firewall rules stored in the master database.

    These rules can only be modified by.

    The server-level principal login (the original SQL admin created during server setup)

    Or an Azure Active Directory (AD) admin assigned to the SQL server

    Become the Azure AD Admin for the SQL Server

    You must be set as the Active Directory admin on the SQL logical server-not just the database.

    • Go to the SQL server (not the database) in the Azure portal.
    • Under Settings, click Active Directory admin.
    • If your account isn’t listed, click Set admin, choose your user, then Save.
    • Sign out and back in to refresh your permissions.

    Delete the Grayed-Out IPs via Portal

    In Azure Portal:

    • Go to the SQL server --> Firewalls and virtual networks.
    • You should now be able to click the trash icon next to the grayed-out IPs and Save.

    In T-SQL (SQL Server Management Studio or Azure Data Studio):

    • Make sure you connect to the master database using your Azure AD admin credentials.
    --Connect to master database
    USE master;
    --Delete the rule
    EXEC sp_delete_firewall_rule @name = N'ClientIPAddress_2023-06-28_01:06:27';
    --Optional: Refresh cache
    DBCC FLUSHAUTHCACHE;
    

    If you get the error “User must be in the master database,” it means you're connected to the wrong database. Switch to master before running the command.

    Note: Grayed-out firewall rules in Azure SQL Database can only be deleted by the server-level principal login or an Azure Active Directory (AD) admin.

    Please refer this document:

    https://learn.microsoft.com/en-us/azure/azure-sql/database/firewall-configure?view=azuresql&source=recommendations

    Let me know if you need more details, happy to assist you further

    Thanks,

    Kalyani

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.