Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared Image Gallery Definition Failure #26

Closed
Thomas-Butterfield opened this issue Feb 21, 2023 · 4 comments
Closed

Shared Image Gallery Definition Failure #26

Thomas-Butterfield opened this issue Feb 21, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Thomas-Butterfield
Copy link
Contributor

Hi Walid,

I came across a condition where the else throw statement in Get-SHRLatestImageVersion.ps1 causes the function to fail. In my case I want to provide only an image definition in my build parameters and not a specific version as in your example.

$imageReference.id = /subscriptions/<subscriptionId>/resourceGroups/<resource-group>/providers/Microsoft.Compute/galleries/<galleryname>/images/<imageDefinitionName>

I'm providing a valid input but it doesn't match the $imageVersionResourceIdPattern. The function fails at the throw, but by simply removing this else block I'm able to build from the gallery without issue.

        if ($ImageReference.Id -match $imageVersionResourceIdPattern ) {
            Write-PSFMessage -Level Host -Message 'Image reference is an Image Version resource.'
            $imageVersion = Get-AzGalleryImageVersion -ResourceId $ImageReference.Id
            $azImageVersion = $imageVersion.Name
            $azImageDate = $imageVersion.PublishingProfile.PublishedDate
            Write-PSFMessage -Level Host -Message "Image version is {0} and date is {1}" -StringValues $azImageVersion, $azImageDate.ToString('o')
        }
        #else {
        #    throw "Image reference Id does not match expected format for an Image Definition resource."
       # }

I'd assume the other final else throw block should be sufficient for error handling?

    else {
        throw "Image reference does not contain a publisher or Id property. ImageReference, publisher, and Id are case sensitive!!"
    }
@WillyMoselhy
Copy link
Owner

This was fixed with the pattern update you made, right?

@WillyMoselhy WillyMoselhy self-assigned this Feb 22, 2023
@WillyMoselhy WillyMoselhy added the bug Something isn't working label Feb 22, 2023
@Thomas-Butterfield
Copy link
Contributor Author

The PR only addressed the custom App Plan feature and fixed the Regex, I didn't want to remove the 'else throw' block without flagging it here to you first.

I'd suggest we simply remove the 'else throw' block entirely from the Get-SHRLatestImageVersion.ps1 at lines 81-83 or we need to duplicate the entire blocks above which seems a little redundant and uses an additional parameter to differentiate between Shared Image Gallery Types.

$ImageReference.Version
$imageRererence.Id

@Thomas-Butterfield
Copy link
Contributor Author

See #33

@Thomas-Butterfield
Copy link
Contributor Author

This was resolved in the downscaling host pool release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants