Azure SQL Database cannot be deleted - stale Job Agent association

Hans-Christian Höpfl 0 Reputation points
2026-09-14T10:08:34.76+00:00

Hello, I cannot delete an Azure SQL Database because Azure reports: CannotMoveOrDropJobAccountDatabase "The database confis001dev on server conservis01 is used by job account SQL Agent. Database cannot be deleted or renamed while associated with job account." Environment: Resource Group: Conservis SQL Server: conservis01 Database: confis001dev Region: West Europe Using the Azure REST API, I found the following Job Agent: Name: SQL Agent State: Ready SKU: JA100 The Job Agent has the following databaseId: /subscriptions/<subscription-id>/resourceGroups/Conservis/providers/Microsoft.Sql/servers/conservis01/databases/confis001dev However, the Job Agent appears to be in an inconsistent state. GET on the individual Job Agent returns ParentResourceNotFound. GET on: /jobAgents/SQL Agent/jobs also returns ParentResourceNotFound. DELETE on the Job Agent returns HTTP 204, but the Job Agent remains listed afterwards with state "Ready" and still references confis001dev. The database itself cannot be deleted. How can I remove this stale Job Agent association so that the database can be deleted? Thank you.

Azure SQL Database

1 answer

Sort by: Newest
  1. Deepesh Dhake 1,165 Reputation points
    2026-09-14T13:39:03.3233333+00:00

    You can try these steps, in order

    1. Wait and re-check: In the documented case, the agent was initially absent from the server and only appeared after ARM cache synchronization, after which the database deleted successfully. If this state is fresh, give it a few hours and re-GET the agent before doing anything else.
    2. Verify with a clean, correctly formed call: Use the current API version and URL-encode the space in the agent name:
       az rest --method get \
    --uri "https://management.azure.com/subscriptions/<sub>/resourceGroups/Conservis/providers/Microsoft.Sql/servers/conservis01/jobAgents/SQL%20Agent?api-version=2025-01-01"
    

    A malformed path can itself produce ParentResourceNotFound, so rule that out first.

    1. Check for resource locks on the RG, server, or database, a lock makes DELETE report success without acting:
       az lock list --resource-group Conservis
    
    

    Was this answer helpful?

    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.