Skip to content

Use az group exists instead of az group show for resource group existence checks#158

Merged
simonkurtz-MSFT merged 4 commits intomainfrom
copilot/fix-use-az-group-exists
Feb 26, 2026
Merged

Use az group exists instead of az group show for resource group existence checks#158
simonkurtz-MSFT merged 4 commits intomainfrom
copilot/fix-use-az-group-exists

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

does_resource_group_exist was relying on az group show returning an error to infer a group doesn't exist — basing control flow on error conditions rather than clean boolean output.

Changes

  • shared/python/azure_resources.py: Switch does_resource_group_exist to az group exists, which returns true/false without errors.
# Before
output = run(f'az group show --name {resource_group_name} -o json')
return output.success

# After
output = run(f'az group exists --name {resource_group_name}')
return output.success and output.text.strip().lower() == 'true'
  • tests/python/test_azure_resources.py: Updated tests to reflect the new command and output format. Notably, az group exists always exits cleanly (exit code 0) — existence is determined by the true/false text output, not the return code.
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: Use az group exists instead of az group show when checking whether group exists</issue_title>
<issue_description>### Describe the bug

Consider using az group exists instead of az group show when we check for the presence of a resource group (before creation, etc.). The latter returns an error when the resource group doesn't exist. While this has worked, we should not base logic on errors.

To Reproduce

Run an infrastructure creation with the log level on DEBUG to see it.

Expected behavior

Not base logic on an error.

Screenshots

No response

CPU Architecture

None

Other CPU Architecture

No response

Operating System

None

Other Operating System

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…rce group existence

Co-authored-by: simonkurtz-MSFT <84809797+simonkurtz-MSFT@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug by using az group exists for checking group presence Use az group exists instead of az group show for resource group existence checks Feb 25, 2026
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

🐍 Python 3.14 Results

Metric Status Value
Ruff 0 issue(s)
Unit Tests success
Code Coverage 📊 100%

Full Workflow Logs

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Python 3.14 Detailed Test Results

1 562 tests  +1   1 562 ✅ +1   11s ⏱️ -4s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 0d08d5f. ± Comparison against base commit ae7fd7d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

🐍 Python 3.12 Results

Metric Status Value
Ruff 0 issue(s)
Unit Tests success
Code Coverage 📊 100%

Full Workflow Logs

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

🐍 Python 3.13 Results

Metric Status Value
Ruff 0 issue(s)
Unit Tests success
Code Coverage 📊 100%

Full Workflow Logs

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Python 3.12 Detailed Test Results

1 562 tests  +1   1 562 ✅ +1   16s ⏱️ -1s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 0d08d5f. ± Comparison against base commit ae7fd7d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Python 3.13 Detailed Test Results

1 562 tests  +1   1 562 ✅ +1   15s ⏱️ ±0s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 0d08d5f. ± Comparison against base commit ae7fd7d.

♻️ This comment has been updated with latest results.

@simonkurtz-MSFT simonkurtz-MSFT added the enhancement New feature or request label Feb 26, 2026
@simonkurtz-MSFT simonkurtz-MSFT marked this pull request as ready for review February 26, 2026 00:05
@simonkurtz-MSFT simonkurtz-MSFT merged commit d77e4e6 into main Feb 26, 2026
9 checks passed
@simonkurtz-MSFT simonkurtz-MSFT deleted the copilot/fix-use-az-group-exists branch February 26, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Use az group exists instead of az group show when checking whether group exists

2 participants