Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

Import-AzContainerRegistryImage - Missing property parameters.TargetTags Error #24546

Open jopalhei opened 5 months ago

jopalhei commented 5 months ago

Description

This process was working fine previously. From the official documentation the parameter '-TargetTag' isn't a required parameter. 'When tag is omitted the source will be used (or 'latest' if source tag is also omitted).'

Scenario : Importing an Image from an ACR in a different subscription but same AD tenant . Both source and destination ACR's are not Azure Gov Cloud.

Error: Import-AzContainerRegistryImage_ImportExpanded: Missing property parameters.TargetTags for the operation against the resource with name .

Expected Behavior : Since '-TargetTag' isn't a required parameter this error shouldn't occur in any situation.

Workaround : Adding the parameter '-TargetTag' with a value equals to the source image resolves the issue.

Issue script & Debug output

PS C:\Users\nnjn> $ImportParams = @{
>>   SourceRegistryResourceId = '/subscriptions/subguid/resourceGroups/resgroupname/providers/Microsoft.ContainerRegistry/registries/sourceregistry'
>>   ResourceGroupName        = 'resgroupname'
>>   RegistryName             = 'sourceregistry'
>>   SourceImage              = 'tenant/imagename:1.2.27'
>>   Mode                     = 'Force'
>> }
PS C:\Users\nnjn> Import-AzContainerRegistryImage @ImportParams
DEBUG: 10:14:41 - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 10:14:41 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:14:41 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 10:14:41 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:14:41 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:14:41 - GetAzureRMContextCommand end processing.
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /subscriptions/subguid/resourceGroups/resgroupname/providers/Microsoft.ContainerRegistry/registries/destregistry/importImage?api-version=2023-01-01-preview
DEBUG: RequestCreated: /subscriptions/subguid/resourceGroups/resgroupname/providers/Microsoft.ContainerRegistry/registries/destregistry/importImage?api-version=2023-01-01-preview
DEBUG: HeaderParametersAdded:
DEBUG: BodyContentSet:
DEBUG: 10:14:41 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://management.azure.com/subscriptions/subguid/resourceGroups/resgroupname/providers/Microsoft.ContainerRegistry/registries/destregistry/importImage?api-version=2023-01-01-preview

Headers:
x-ms-unique-id                : 4
x-ms-client-request-id        : 62593303-e3e0-45ab-8d13-a5c441644a17
CommandName                   : Import-AzContainerRegistryImage
FullCommandName               : Import-AzContainerRegistryImage_ImportExpanded
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v11.4.0,PSVersion/v7.4.1,Az.ContainerRegistry/4.1.3

Body:
{
  "source": {
    "resourceId": "/subscriptions/subguid/resourceGroups/resgroupname/providers/Microsoft.ContainerRegistry/registries/sourceregistry",
    "sourceImage": 'tenant/imagename:1.2.27'
  },
  "mode": "Force"
}

DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
BadRequest

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
x-ms-ratelimit-remaining-subscription-writes: 1199
Strict-Transport-Security     : max-age=31536000; includeSubDomains
api-supported-versions        : 2017-10-01, 2019-05-01, 2019-12-01-preview, 2020-11-01-preview, 2021-06-01-preview, 2021-08-01-preview, 2021-09-01, 2021-12-01-preview, 2022-02-01-preview, 2022-12-01, 2023-01-01-preview, 2023-06-01-preview, 2023-07-01, 2023-08-01-preview, 2023-11-01-preview, 2024-01-01-preview, 2024-11-01-preview
Server                        : Kestrel
x-ms-request-id               : 9225187d-d245-45f8-9169-67d853d66c22
x-ms-correlation-request-id   : 9225187d-d245-45f8-9169-67d853d66c22
x-ms-routing-request-id       : WESTEUROPE:20240328T101442Z:9225187d-d245-45f8-9169-67d853d66c22
X-Content-Type-Options        : nosniff
Date                          : Thu, 28 Mar 2024 10:14:42 GMT

Body:
{
  "error": {
    "code": "MissingRequiredParameter",
    "message": "Missing property parameters.TargetTags for the operation against the resource with name destregistry."
  },
  "status": "Failed"
}

DEBUG: ResponseCreated:
DEBUG: [Finally]: Getting exception 'Microsoft.Azure.Commands.Common.Exceptions.AzPSCloudException: InternalException' from response
DEBUG: Finally:
Import-AzContainerRegistryImage_ImportExpanded: Missing property parameters.TargetTags for the operation against the resource with name coricengage00gqozoglaz3r54.
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent:  Module: Az.ContainerRegistry:4.1.3; CommandName: Import-AzContainerRegistryImage; PSVersion: 7.4.1; IsSuccess: False; Duration: 00:00:01.5718955; Exception: InternalException;

Environment data

PS C:\Users\nnjn> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0???}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

Get-InstalledModule -Name Az -AllVersions | select Name,Version  

Name Version
---- -------
Az   11.2.0
Az   11.3.1
Az   11.4.0

Error output

PS C:\Users\nnjn> Resolve-AzError
DEBUG: 10:18:53 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 10:18:53 - using account id 'useraccount@'...
DEBUG: 10:18:53 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:18:53 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [False].

   HistoryId: 11

Message        : Missing property parameters.TargetTags for the operation against the resource with name
                 destregistry.
StackTrace     :    at Microsoft.Azure.PowerShell.Cmdlets.ContainerRegistry.ContainerRegistry.RegistriesImportImage_Cal
                 l(HttpRequestMessage request, Func`2 onOk, IEventListener eventListener, ISendAsync sender)
                    at Microsoft.Azure.PowerShell.Cmdlets.ContainerRegistry.ContainerRegistry.RegistriesImportImage_Cal
                 l(HttpRequestMessage request, Func`2 onOk, IEventListener eventListener, ISendAsync sender)
                    at
                 Microsoft.Azure.PowerShell.Cmdlets.ContainerRegistry.ContainerRegistry.RegistriesImportImage(String
                 subscriptionId, String resourceGroupName, String registryName, IImportImageParameters body, Func`2
                 onOk, IEventListener eventListener, ISendAsync sender)
                    at Microsoft.Azure.PowerShell.Cmdlets.ContainerRegistry.Cmdlets.ImportAzContainerRegistryImage_Impo
                 rtExpanded.ProcessRecordAsync()
Exception      : Microsoft.Azure.PowerShell.Cmdlets.ContainerRegistry.Runtime.UndeclaredResponseException
InvocationInfo : {Import-AzContainerRegistryImage_ImportExpanded}
Line           : Import-AzContainerRegistryImage @ImportParams
Position       : At line:1 char:1
                 + Import-AzContainerRegistryImage @ImportParams
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 11

DEBUG: 10:18:53 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:18:53 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent:  Module: Az.Accounts:2.16.0; CommandName: Resolve-AzError; PSVersion: 7.4.1; IsSuccess: True; Duration: 00:00:00.0590384
DEBUG: 10:18:53 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:18:53 - ResolveError end processing.
isra-fel commented 4 months ago

Thanks for reporting.