Azure / Azure/azure-cli

'az resource tag' doesn’t work with snapshots from images with legal terms

Open
#17,246 1 comment 0 reactions 1 assignee Claimed by @zhoxing-ms View on GitHub
act-identity-squad ARM feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

## Describe the bug

**Command Name**
`az resource tag`

**Errors:**

```text
This subscription is not registered to use Microsoft.Compute/TestSubscription feature.
```

## To Reproduce

- Create resource group: `az group create --location westeurope --resource-group 'rg-kali'`
- Attempt to create Kali Linux virtual machine:

```console
$ az vm create \
--name 'vm-kali' \
--resource-group 'rg-kali' \
--admin-username 'test-user' \
--image 'kali-linux:kali-linux:kali:2019.2.0' \
--ssh-key-values @~/.ssh/id_rsa.pub

Azure Error: MarketplacePurchaseEligibilityFailed
Message: Marketplace purchase eligibilty check returned errors. See inner errors for details.
Exception Details:
Error Code: BadRequest
Message: Offer with PublisherId: 'kali-linux', OfferId: 'kali-linux' cannot be purchased due to validation errors.

```

- Agree to terms:

```console
$ az vm image terms accept --offer 'kali-linux' --plan 'kali' --publisher 'kali-linux'
{
"accepted": true,

}
```

- Create Kali Linux VM:

```console
$ az vm create \
--name 'vm-kali' \
--resource-group 'rg-kali' \
--admin-username 'test-user' \
--image 'kali-linux:kali-linux:kali:2019.2.0' \
--ssh-key-values @~/.ssh/id_rsa.pub

{- Finished ..

}
```

- Stop VM:

```console
$ az vm stop --name 'vm-kali' --resource-group 'rg-kali'
About to power off the specified VM...
It will continue to be billed. To deallocate a VM, run: az vm deallocate.
```

- Get VM disk's managed ID:

```console
$ az vm show \
--name 'vm-kali' \
--resource-group 'rg-kali' \
--query 'storageProfile.osDisk.managedDisk.id' --out tsv

```

- Create snapshot from VM disk without initial tags:

```console
$ az snapshot create --name 'snp-kali' --resource-group 'rg-kali' --source
{- Finished ..

}
```

- Attempt to tag snapshot using `az resource tag`:

```console
$ az resource tag \
--tags my-tag=my-value \
--resource-group 'rg-kali' \
--name 'snp-kali' \
--resource-type 'Microsoft.Compute/snapshots'

This subscription is not registered to use Microsoft.Compute/TestSubscription feature.
```

## Expected Behavior

For:

- the command to succeed, or;
- the error message to be more descriptive if for some reason the command cannot be fixed to succeed.

## Environment Summary

```text
Linux-5.10.19-200.fc33.x86_64-x86_64-with-glibc2.32
Python 3.9.2
Installer: RPM

azure-cli 2.20.0
```

## Additional Context

Found the following related to this:

- if one creates an image (`Microsoft.Compute/images`) instead of a snapshot (`Microsoft.Compute/snapshots`), then tagging with `az resource tag` **will succeed**;
- using `az tag create` to tag, regardless of the type of resource, **will succeed**

I have not tested other images from the Azure Marketplace that have legal terms attached to them.

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.