Correct the DB_ID finding: documented Azure behaviour, sample-code problem #1

Merged
hannah-vernon merged 1 commit from fix/db-id-wording into dev 2026-11-19 16:19:36 -05:00
Owner

What does this PR do?

Corrects the README's DB_ID() finding. It said the behaviour "may be intended". Microsoft's DB_ID documentation confirms it: in Azure SQL Database, DB_ID returns an ID only for the current database, and NULL for any other. The container is faithful to Azure. The problem is the IF DB_ID('appdb') IS NULL CREATE DATABASE appdb; guard in Microsoft's getting started guide and agent skills, which fails with Msg 1801 on a rerun against a persistent volume, and can wait forever inside the skills' wait loops.

Fixes #

How was this tested?

Documentation change only. The behaviour it describes was verified on the lab container before this change: on a master connection DB_ID(N'appdb') returns NULL while sys.databases reports database_id 6, and from inside appdb DB_ID() returns 6.

  • PowerShell files parse in Windows PowerShell 5.1 and PowerShell 7 (no PowerShell changes)
  • shellcheck scripts/*.sh compose/*.sh is clean (no shell changes)
  • Started the lab, ran sql/build-check.sql and tests/change-tracking/Test-ChangeTracking.ps1, and stopped it (not needed for a wording change)
  • Runtime and platform: Windows 11, WSL 2 Debian 13, Docker 29.8.2, Compose 5.6.0
  • Image digest: sha256:8323f47dad34124f391413c3c3182ca89da5632888df6cfb5326574026599c57

Checklist

  • I have read the Contributing Guide
  • Changes are focused - one logical change per PR
  • Documentation updated (if user-visible behaviour changed)
  • The password never reaches a command line, an environment variable of a host process, a log, docker inspect or the console
  • No real host names, databases, passwords or customer data
  • No commented-out code or debug leftovers
## What does this PR do? Corrects the README's `DB_ID()` finding. It said the behaviour "may be intended". Microsoft's DB_ID documentation confirms it: in Azure SQL Database, `DB_ID` returns an ID only for the current database, and NULL for any other. The container is faithful to Azure. The problem is the `IF DB_ID('appdb') IS NULL CREATE DATABASE appdb;` guard in Microsoft's getting started guide and agent skills, which fails with Msg 1801 on a rerun against a persistent volume, and can wait forever inside the skills' wait loops. Fixes # ## How was this tested? Documentation change only. The behaviour it describes was verified on the lab container before this change: on a `master` connection `DB_ID(N'appdb')` returns NULL while `sys.databases` reports database_id 6, and from inside `appdb` `DB_ID()` returns 6. - [ ] PowerShell files parse in Windows PowerShell 5.1 and PowerShell 7 (no PowerShell changes) - [ ] `shellcheck scripts/*.sh compose/*.sh` is clean (no shell changes) - [ ] Started the lab, ran `sql/build-check.sql` and `tests/change-tracking/Test-ChangeTracking.ps1`, and stopped it (not needed for a wording change) - [x] Runtime and platform: Windows 11, WSL 2 Debian 13, Docker 29.8.2, Compose 5.6.0 - [x] Image digest: sha256:8323f47dad34124f391413c3c3182ca89da5632888df6cfb5326574026599c57 ## Checklist - [x] I have read the [Contributing Guide](../CONTRIBUTING.md) - [x] Changes are focused - one logical change per PR - [x] Documentation updated (if user-visible behaviour changed) - [x] The password never reaches a command line, an environment variable of a host process, a log, `docker inspect` or the console - [x] No real host names, databases, passwords or customer data - [x] No commented-out code or debug leftovers
The DB_ID page documents that DB_ID returns an ID only for the current database in Azure SQL Database.  Reword the finding so it blames the IF DB_ID(...) IS NULL guard in Microsoft's samples and skills, not the engine.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hannah-vernon/azure-sql-db-container-lab!1
No description provided.