Skip to content

fix: sql server review findings - #7528

Open
Arjen Huitema (arjenhuitema) wants to merge 14 commits into
mainfrom
fix-sql-server-review-findings
Open

Arjen Huitema (arjenhuitema) wants to merge 14 commits into
mainfrom
fix-sql-server-review-findings

Conversation

@arjenhuitema

@arjenhuitema Arjen Huitema (arjenhuitema) commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

Pipeline Reference

Pipeline
avm.res.sql.server

Type of Change

  • Azure Verified Module updates:
    • Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in version.json:
    • Feature update backwards compatible feature updates, and I have bumped the MINOR version in version.json.
    • Breaking changes and I have bumped the MAJOR version in version.json.
    • Update to documentation
  • Update to CI Environment or utilities (Non-module affecting changes)

Checklist

  • I'm sure there are no other open Pull Requests for the same update/change
  • I have run Set-AVMModule locally to generate the supporting module files.
  • My corresponding pipelines / checks run clean and green without any errors or warnings
  • I have updated the module's CHANGELOG.md file with an entry for the next version

- Fix elastic pool role assignments not being passed to the child module
- Secure securityAlertPolicies storageAccountAccessKey
- Add server diagnostic settings (master database) to route audit logs
- Add express vulnerability assessment configuration
- Add database role assignments and elastic pool diagnostic settings
- Add databases and elasticPools outputs
- Remove retired TLS 1.0/1.1, make publicNetworkAccess nullable
- Add validations (administrators, primary UAI, secrets export, failover group, VA config)
- Default LTR immutability mode to Unlocked
- Support partner server resource IDs for failover group read-only endpoint
- Support UAI-only servers for vulnerability assessment storage access
- Fix case-sensitive identity / HSM matching and sovereign cloud HSM URIs
- Remove ignored enableTelemetry properties from child types
- Align avm-common-types to 0.7.0 and tags API versions
- Rename encryption-protector sqlServerName to serverName
- Update WAF-aligned and max tests, changelogs and versions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eference

The case-insensitive '=~' comparison on a safe-dereferenced array index (which returns null when no CMK is configured) caused an ARM deployment-time error ('toLower expects String, got Null'). Coalesce to an empty string before the comparison. Found via live deployment validation (what-if).

Also includes a doc-only refresh of two README 'local references' tables to avm-common-types 0.7.0 that a prior README regeneration pass had missed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-verified-modules azure-verified-modules Bot added the Needs: Module Owner 📣 This module needs an owner to develop or maintain it label Oct 12, 2026
@azure-verified-modules
azure-verified-modules Bot requested a review from a team October 12, 2026 22:23
The parent README's 'local references' table still listed superseded avm-common-types versions (0.5.1, 0.6.0, 0.6.1) from before they were bumped to 0.7.0. Re-ran Set-AVMModule (-SkipBuild) to regenerate the table, which CI's 'Set-ModuleReadMe script should not apply any updates' test caught as stale.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
name: '${uniqueString(deployment().name, resourceLocation)}-nestedDependencies'
params: {
storageAccountName: 'dep${namePrefix}audstore${serviceShort}'
storageAccountName: 'dep${namePrefix}audstore${serviceShort}${substring(uniqueString(baseTime), 0, 3)}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using baseTime would be an option but may re-runs a bit tough if one wants to re-run the test.

How about e.g., subscription().id instead: 'dep${namePrefix}st${serviceShort}${substring(uniqueString(subscription().id), 0, 4)}'

@AlexanderSehr Alexander Sehr (AlexanderSehr) Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comment applies to other resources & files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alexander Sehr (@AlexanderSehr), agreed. This is now addressed in the PR: ordinary SQL/Key Vault fixture names use a stable suffix derived from subscription().id, including the other affected scenarios.

For the audit and vulnerability-assessment storage accounts, I kept main's stronger naming expression: an 11-character readable prefix plus uniqueString(resourceGroup.id, namePrefix, serviceShort). This stays stable across reruns, distinguishes resource groups and subscriptions, and fits the 24-character storage-account limit.

The only intentional baseTime exception is the shared Managed HSM test's key names, where it is retained to create fresh test keys.

Co-authored-by: Alexander Sehr <ASehr@hotmail.de>
Preserve the released master-database diagnostics interface and the author's release-note fix. Stabilize SQL fixture names, regenerate artifacts, and add focused regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve published SQL release history and pending fixes, retain resource-group-scoped storage naming and deployment ordering, and regenerate merged templates with the managed authoring toolchain.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

E2E label requirement satisfied

No E2E label action is needed for this run. This does not mean validation has passed.

View PR-check run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The auditing configuration grants storage permissions to the system-assigned identity instead of the primary user-assigned identity SQL auditing uses, leaving blob auditing without required access.

3 open issues
What changed in this PR

This PR addresses review findings in the Azure SQL Server AVM module and its child modules, expanding configuration support and tightening deployment validation.

Changes:

  • Adds express vulnerability assessments, database role assignments, elastic-pool diagnostics, and child-resource outputs.
  • Updates identity handling, encryption-key URLs, failover validation, and backup immutability defaults.
  • Revises deployment fixtures, adds naming and diagnostic regression tests, and updates documentation and release metadata.
File Description
avm/​res/​sql/​server/​vulnerability-assessment/​README.md Documents managed-identity selection.
avm/​res/​sql/​server/​vulnerability-assessment/​modules/​nested_storageRoleAssignment.bicep Renames the principal-ID parameter.
avm/​res/​sql/​server/​vulnerability-assessment/​main.json Updates the compiled assessment template.
avm/​res/​sql/​server/​vulnerability-assessment/​main.bicep Adds identity fallback and shortens deployment names.
avm/​res/​sql/​server/​vulnerability-assessment/​CHANGELOG.md Records assessment fixes.
avm/​res/​sql/​server/​version.json Advances the server module version.
avm/​res/​sql/​server/​tests/​unit/​regression.tests.ps1 Adds naming and master-database diagnostic checks.
avm/​res/​sql/​server/​tests/​e2e/​waf-aligned/​main.test.bicep Updates naming, vulnerability assessment, networking, and backups.
avm/​res/​sql/​server/​tests/​e2e/​waf-aligned/​dependencies.bicep Removes the unused service-endpoint subnet.
avm/​res/​sql/​server/​tests/​e2e/​vulnAssm/​main.test.bicep Adds a subscription-derived server suffix.
avm/​res/​sql/​server/​tests/​e2e/​max/​main.test.bicep Updates naming and exercises diagnostics and database permissions.
avm/​res/​sql/​server/​tests/​e2e/​failover-group/​main.test.bicep Uses the secondary server resource ID.
avm/​res/​sql/​server/​tests/​e2e/​cmk-uami/​main.test.bicep Changes Key Vault naming.
avm/​res/​sql/​server/​tests/​e2e/​audit/​main.test.bicep Adds a subscription-derived server suffix.
avm/​res/​sql/​server/​README.md Documents updated interfaces and examples.
avm/​res/​sql/​server/​modules/​keyVaultExport.bicep Updates the shared secret type dependency.
avm/​res/​sql/​server/​main.bicep Adds capabilities, validation, identity defaults, and outputs.
avm/​res/​sql/​server/​failover-group/​README.md Clarifies partner IDs and conditional requirements.
avm/​res/​sql/​server/​failover-group/​main.json Updates compiled failover handling.
avm/​res/​sql/​server/​failover-group/​main.bicep Accepts partner IDs and validates automatic failover.
avm/​res/​sql/​server/​failover-group/​CHANGELOG.md Records failover fixes.
avm/​res/​sql/​server/​encryption-protector/​version.json Advances the child module version.
avm/​res/​sql/​server/​encryption-protector/​README.md Documents the renamed server parameter.
avm/​res/​sql/​server/​encryption-protector/​main.json Updates compiled parameter references.
avm/​res/​sql/​server/​encryption-protector/​main.bicep Renames sqlServerName to serverName.
avm/​res/​sql/​server/​encryption-protector/​CHANGELOG.md Records the breaking parameter rename.
avm/​res/​sql/​server/​elastic-pool/​version.json Advances the elastic-pool version.
avm/​res/​sql/​server/​elastic-pool/​README.md Documents diagnostic settings.
avm/​res/​sql/​server/​elastic-pool/​main.json Updates compiled diagnostics and role-assignment naming.
avm/​res/​sql/​server/​elastic-pool/​main.bicep Adds diagnostics and pool-scoped assignment GUIDs.
avm/​res/​sql/​server/​elastic-pool/​CHANGELOG.md Records diagnostics and assignment-name changes.
avm/​res/​sql/​server/​database/​version.json Advances the database module version.
avm/​res/​sql/​server/​database/​README.md Documents role assignments and retention defaults.
avm/​res/​sql/​server/​database/​main.json Updates compiled permissions, encryption, and retention handling.
avm/​res/​sql/​server/​database/​main.bicep Adds role assignments and cloud-aware HSM URLs.
avm/​res/​sql/​server/​database/​CHANGELOG.md Records database features and breaking changes.
avm/​res/​sql/​server/​database/​backup-long-term-retention-policy/​version.json Advances the retention-policy version.
avm/​res/​sql/​server/​database/​backup-long-term-retention-policy/​README.md Documents the unlocked immutability default.
avm/​res/​sql/​server/​database/​backup-long-term-retention-policy/​main.json Updates the compiled immutability default.
avm/​res/​sql/​server/​database/​backup-long-term-retention-policy/​main.bicep Defaults enabled immutability to Unlocked.
avm/​res/​sql/​server/​database/​backup-long-term-retention-policy/​CHANGELOG.md Records the breaking default change.
avm/​res/​sql/​server/​CHANGELOG.md Summarizes server features and compatibility changes.
avm/​res/​sql/​server/​auditing-setting/​README.md Clarifies audit routing and optional storage configuration.
avm/​res/​sql/​server/​auditing-setting/​main.json Updates compiled identity and storage handling.
avm/​res/​sql/​server/​auditing-setting/​main.bicep Revises identity lookup, validation, and storage-key retrieval.
avm/​res/​sql/​server/​auditing-setting/​CHANGELOG.md Records auditing fixes and documentation updates.

Review effort: Balanced

Clarified breaking change regarding role assignment naming conventions and provided guidance for upgrading existing assignments.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…es Add regression coverage for identity selection and per-run Key Vault naming.
$names = (Get-Content -LiteralPath $outputPath -Raw | ConvertFrom-Json -AsHashtable).parameters
}

It 'Keeps ordinary resource names stable across reruns and init/idem iterations' {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that Pester test cases ideally make use of the -TestCases or ForEach parameters to iterate through a group of tests as opposed to loop inside the test.
The reason is simply that Pester will otherwise fail the test on the very first item that does not pass the Should as opposed to running through the full group and letting you know how many of them passed/failed

Comment on lines +34 to +39
foreach ($scopeIndex in 0..1) {
$subscription = @('11111111-1111-1111-1111-111111111111', '22222222-2222-2222-2222-222222222222')[$scopeIndex]
foreach ($prefix in @('avm', 'test', 'longprefix')) {
$groupId = "/subscriptions/$subscription/resourceGroups/dep-$prefix-sql.servers-$service-rg"
foreach ($attempt in 1..2) {
foreach ($iteration in @('init', 'idem')) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very compliacted. Is there a specific reason so much emphasis is put on the naming for multiple scopes/attemts/iterations...?

The same question goes for the test cases below. Kudos for putting in so much work, but I have honestely a bit of a hard time to fully comprehend what is tested here - calling into question how well maintainable it may be 😄

Comment on lines +23 to +24
@description('Optional. A unique token for this test run. Reuse it when retrying the same active deployment to keep the Key Vault name unchanged.')
param vaultRunToken string = newGuid()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of using newGUID() over a utcNow() paramter with both being parameters that can be overwritten?

Comment on lines +28 to +29
@description('Optional. A unique token for this test run. Reuse it when retrying the same active deployment to keep the Key Vault name unchanged.')
param vaultRunToken string = newGuid()

@AlexanderSehr Alexander Sehr (AlexanderSehr) Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as before

Comment on lines +24 to +25
@description('Optional. A unique token for this test run. Reuse it when retrying the same active deployment to keep the Key Vault name unchanged.')
param vaultRunToken string = newGuid()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And again the same question as before

Comment on lines +514 to +516
name: expressVulnerabilityAssessmentState == 'Enabled'
? fail('The classic vulnerability assessment configuration (\'vulnerabilityAssessmentsObj\') cannot be combined with the express configuration (\'expressVulnerabilityAssessmentState\' set to \'Enabled\').')
: vulnerabilityAssessmentsObj!.name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subjectively it's a bit confusing to have this check here in the name. I'd propose to keep it as is, and move the check to a variable like

var checkVulnerabilityAssessmentConfig =  expressVulnerabilityAssessmentState == 'Enabled' && vulnerabilityAssessmentsObj != null ? fail('The classic vulnerability assessment configuration (\'vulnerabilityAssessmentsObj\') cannot be combined with the express configuration (\'expressVulnerabilityAssessmentState\' set to \'Enabled\').') : 'pass'

Otherwise it feels a bit odd that the check is here, but e.g., not implemented at the server_sqlVulnerabilityAssessment block - and if moved to it's own variable, it 'feels' a bit more consistent. What do you think?

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Module Owner 📣 This module needs an owner to develop or maintain it PR: Run Required E2E Tests Run required end-to-end tests for this pull request. Type: AVM 🅰️ ✌️ Ⓜ️ This is an AVM related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants