Azure SQL Database Delete issue

Mert Yacan 0 Reputation points
2024-07-02T06:04:57.22+00:00

Hi Azure Support Team,

I am encountering an issue where a SQL database that I deleted reappeared and caused unexpected high costs on our Azure account.

Background:

  • On June 11, my boss asked me to review our Azure bill and remove any unnecessary resources. I am the only person actively using Azure in our company.

I found a SQL database resource costing $5 per month and deleted it on that day. I saw the deletion completion message.

Issue:

  • A week ago, I noticed an extra $200 charge on our Azure cost report. Upon investigation, I found that the SQL database I had deleted was still there and had been recreated.
  • After spending some time to understand what happened, it seems that an unused API was attempting to access the SQL database using a SQL connection string with SQL user credentials. This action appears to have caused the SQL server to automatically recreate the SQL database.
  • Only after I removed the SQL server, I was able to delete SQL database.

My expected behavior:

  • I remove a database and any other resource trying to use it will just stop working.

Questions:

Expected Behavior or Bug?: Is this automatic recreation of the SQL database expected behavior, or is it a bug? I was under the impression that resource creation required explicit actions via Azure Web Application or Application Registration.

Cost Discrepancy: We were using a basic level SQL database, which cost $5 per month. How did it turn into a production-level database with significantly higher costs?

Relevant Code:

  • Program.cs
var sqlConBuilder = new SqlConnectionStringBuilder();
sqlConBuilder.ConnectionString = builder.Configuration.GetConnectionString("SQLDbConnection");
builder.Services.AddDbContext<AppDbContext>(opt => opt.UseSqlServer(sqlConBuilder.ConnectionString));
builder.Services.AddScoped<IUsageRepo, UsageRepo>();
  • UsageRepo.cs
public class UsageRepo : IUsageRepo
{
    private readonly AppDbContext _context;
 
    public UsageRepo(AppDbContext context)
    {
        _context = context;
    }
 
    public async Task CreateUsage(Usage usage)
    {
        if (usage == null)
        {
            throw new ArgumentNullException(nameof(usage));
        }
 
        await _context.AddAsync(usage);
    }
    // Other methods...
}

Screenshot of Azure Monitor for deletion logs (There is no log for SQL Database created, after I removed it I can see the database update log with the same database name):

2024-07-02 08_55_11-2024-06-26 15_57_48-Monitor - Microsoft Azure - Brave

Thank you for your support.

Best regards,

Mert

Azure SQL Database
Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,316 questions
{count} votes

1 answer

Sort by: Most helpful
  1. akinbade abiola 8,295 Reputation points
    2024-07-02T08:27:31.66+00:00

    Automatic recreation of the SQL database due to an unused API attempting to access it is not expected behavior. It has to be triggered by something.

    however, If this is the case I will recommend you request dedicated support as they will be able to assist you better.

    https://azure.microsoft.com/en-us/support/create-ticket

    However, I will recommend:

    • Checking if there are any CI/CD pipelines, automation scripts, or deployments that might be recreating the database.
    • Use the Azure Activity Log identify who or what recreated the SQL database.

    You can mark it 'Accept Answer' and 'Upvote' if this helped you

    Regards,

    Abiola

    0 comments No comments