az sig image-version create fails
This is autogenerated. Please review and update as needed.
Describe the bug
Command Name
az sig image-version create
Errors:
'NoneType' object is not subscriptable
Traceback (most recent call last):
python3.6/site-packages/knack/cli.py, ln 215, in invoke
cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 659, in execute
raise ex
cli/core/commands/__init__.py, ln 722, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
...
azure/cli/core/__init__.py, ln 784, in default_command_handler
return op(**command_args)
cli/command_modules/vm/custom.py, ln 3276, in create_image_version
external_bearer_token = external_tokens[0][0] + ' ' + external_tokens[0][1]
TypeError: 'NoneType' object is not subscriptable
To Reproduce:
I set variables and ran three commands:
Variables
subscriptionId="{OMITTED}" location1="eastus2" location2="centralus" rgName="shared" galleryName="sig"
galleryImageDefinition="ws2019" osType="Windows" # Windows or Linux
virtualMachinePublisher="MicrosoftWindowsServer" virtualMachineOffer="WindowsServer" virtualMachineSku="2019-datacenter-smalldisk-g2"
hyperVGeneration="V2" # V1 or V2 osState="Generalized" # Generalized or Specialized
galleryImageVersion="1.0.0" imageResourceId="/subscriptions/""$subscriptionId""/resourceGroups/shared/providers/Microsoft.Compute/images/wi-dev-image-eastus2" # NOTE This is from a generalized/captured VM - can successfully do az create vm with this image resource ID, for example
1. Create Shared Image Gallery (succeeds)
https://docs.microsoft.com/cli/azure/sig?view=azure-cli-latest#az_sig_create
az sig create --subscription "$subscriptionId" -g "$rgName" -l "$location1" --verbose
-r "$galleryName"
2. Create Image Definition (succeeds)
https://docs.microsoft.com/cli/azure/sig/image-definition?view=azure-cli-latest#az_sig_image_definition_create
az sig image-definition create --subscription "$subscriptionId" -g "$rgName" -l "$location1" --verbose
-r "$galleryName" --gallery-image-definition "$galleryImageDefinition" --os-type "$osType"
--publisher "$virtualMachinePublisher" --offer "$virtualMachineOffer" --sku "$virtualMachineSku"
--hyper-v-generation "$hyperVGeneration" --os-state "$osState"
3. Create Image Version (e.g. from custom image from generalized VM)
https://docs.microsoft.com/cli/azure/sig/image-version?view=azure-cli-latest#az_sig_image_version_create
az sig image-version create --subscription "$subscriptionId" -g "$rgName" -l "$location1" --verbose
-r "$galleryName" --gallery-image-definition "$galleryImageDefinition" --gallery-image-version "$galleryImageVersion"
--managed-image "$imageResourceId" --target-regions "$location1" "$location2"
Error happens repeatably. I have tried to modify various arguments to az sig image-version create, same error each time. Example, try only one region, etc.
Expected Behavior
Image version creates successfully.
Environment Summary
Linux-4.19.128-microsoft-standard-x86_64-with-debian-bullseye-sid
Python 3.6.10
Installer: DEB
azure-cli 2.17.1
azure-cli-ml 1.15.0
Extensions:
azure-cli-ml 1.15.0
interactive 0.4.4
azure-firewall 0.7.0
log-analytics 0.2.1
image-copy-extension 0.2.8
Additional Context
hi @qwordy is this fixed?
@plzm Thank you for reporting this issue. It was fixed by https://github.com/Azure/azure-cli/commit/72c2203957760402e115e2056d018aa7a520d7bc. Release date: 01/19/2021
@qwordy Thank you. Which version of azure-cli will that be? I am currently running latest, 2.17.1 on WSL2/Ubuntu 20.04.
BTW there is also an Azure portal problem. When creating a new image version, the portal will not allow existing images in same region to be used, even if it shows them in the image dropdown and same region as selected on image blade is selected. Where should I report what is a possible portal bug for image version creation? Thanks!
It will be 2.18.0.
You can click the "?" button in Portal to report an issue.

Ok, I found a solution, while the new version doesn't come up.
On azure-devops using AzureCli@2
This works fine
az sig image-definition create ....
This doesn't
az sig image-version create ....
So I've downgraded azure-cli and it works
sudo apt-get install -y --allow-downgrades azure-cli=2.14.2-1~xenial
az sig image-version create ....
It takes longer to run, but at least it works.
Here's the output:
> Running command: sudo apt-get install -y --allow-downgrades azure-cli=2.14.2-1~xenial
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be DOWNGRADED:
azure-cli
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 9 not upgraded.
Need to get 50.2 MB of archives.
After this operation, 141 MB disk space will be freed.
Get:1 https://packages.microsoft.com/repos/azure-cli xenial/main amd64 azure-cli all 2.14.2-1~xenial [50.2 MB]
Fetched 50.2 MB in 1s (33.2 MB/s)
dpkg: warning: downgrading azure-cli from 2.17.1-1~xenial to 2.14.2-1~xenial
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 290527 files and directories currently installed.)
Preparing to unpack .../azure-cli_2.14.2-1~xenial_all.deb ...
Unpacking azure-cli (2.14.2-1~xenial) over (2.17.1-1~xenial) ...
Setting up azure-cli (2.14.2-1~xenial) ...
> Creating image version
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"location": "eastus",
"name": "1.0.0",
"provisioningState": "Succeeded",
"publishingProfile": {
"endOfLifeDate": null,
"excludeFromLatest": false,
"publishedDate": "2021-01-16T19:37:21.417348+00:00",
"replicaCount": 1,
"storageAccountType": "Standard_LRS",
"targetRegions": [
{
"encryption": null,
"name": "East US",
"regionalReplicaCount": 1,
"storageAccountType": "Standard_LRS"
}
]
},
"replicationStatus": null,
"resourceGroup": "XXXXXX",
"storageProfile": {
"dataDiskImages": null,
"osDiskImage": {
"hostCaching": "ReadWrite",
"sizeInGb": 127,
"source": {
"id": "XXXXXXXXXXXXX",
"resourceGroup": "XXXXXXXXXX"
}
},
"source": null
},
"tags": {},
"type": "Microsoft.Compute/galleries/images/versions"
}
Hi @brunofitas , Thank you for providing example command to downgrade version. Don't worry. The release on 01/19/2021 is coming.
This was resolved in CLI release 2.18.0. Because it now works, I am closing this issue. Thank you for the deployed fix!
@plzm Glad to know that!