Azure / Azure/azure-cli

az snapshot create does not create a snapshot if the --name already exists and does not report any error

Open
#28,879 1 comment 1 reaction 2 assignees Claimed by @zhoxing-ms View on GitHub
act-observability-squad Auto-Assign Azure CLI Team Compute customer-reported question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Related command**

az snapshot create -g MyResourceGroup -n MySnapshot2 --source "/subscriptions/00000/resource
Groups/AnotherResourceGroup/providers/Microsoft.Compute/disks/MyDisk"

**Is your feature request related to a problem? Please describe.**

When creating a new snapshot, if one of the same name (e.g. MySnapshot2) already exists in MyResourceGroup, the snapshot create command will not overwrite it or report any failure, the exit code is 0. The only clear way to identify this is to compare the timeCreated snapshot value with current time.

**Describe the solution you'd like**

Ideally, snapshot create would report an error or return a non-zero exit status, alternatively it would be nice to pass a flag to overwrite existing snapshots:
az snapshot create -g MyResourceGroup -n MySnapshot2 **--overwrite** --source "/subscriptions/00000/resource
Groups/AnotherResourceGroup/providers/Microsoft.Compute/disks/MyDisk"

doing both would be best.

**Describe alternatives you've considered**

I don't have any alternative, I understand why az snapshot create would not assume it safe to overwrite an existing snapshot, but the command should be more verbose about what action it is or is not taking

**Additional context**

I was unsure if this is a feature request or a bug, current azure-cli version information:
azure-cli 2.60.0

core 2.60.0
telemetry 1.1.0

Extensions:
fzf 1.0.2
resource-graph 2.1.0

Dependencies:
msal 1.28.0
azure-mgmt-resource 23.1.0b2

Python (Darwin) 3.11.9 (main, Apr 2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.