Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/StackHCIVM/StackHCIVM.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ In this directory, run AutoRest:
> see https://aka.ms/autorest

```yaml
commit: 812f964651d5f1f7148b54ed2cc35cb97be12523
commit: abc9cee615e7859ab5cb684a3780066a200324c0
require:
- $(this-folder)/../../readme.azure.noprofile.md

Expand All @@ -64,7 +64,7 @@ input-file:
- $(repo)/specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/virtualHardDisks.json
- $(repo)/specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/virtualMachineInstances.json
- $(repo)/specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/logicalNetworks.json
- $(repo)/specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-03-15-preview/HybridCompute.json
- $(repo)/specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2025-01-13/HybridCompute.json

module-version: 0.1.0
title: StackHCIVM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ PS C:\> {{ Add code here }}


.Outputs
Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IGalleryImages
Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IMarketplaceGalleryImages
Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IGalleryImage
Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IMarketplaceGalleryImage
.Notes
COMPLEX PARAMETER PROPERTIES

.Link
https://learn.microsoft.com/powershell/module/az.stackhcivm/new-azstackhcivmimage
#>
function New-AzStackHCIVMImage{
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IMarketplaceGalleryImages],ParameterSetName='Marketplace' )]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IMarketplaceGalleryImages],ParameterSetName='MarketplaceURN' )]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IGalleryImages],ParameterSetName='GalleryImage' )]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IMarketplaceGalleryImage],ParameterSetName='Marketplace' )]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IMarketplaceGalleryImage],ParameterSetName='MarketplaceURN' )]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IGalleryImage],ParameterSetName='GalleryImage' )]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(

Expand Down Expand Up @@ -103,6 +103,7 @@ function New-AzStackHCIVMImage{
[Parameter(ParameterSetName='GalleryImage', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Body')]
[System.String]

# Local path of image that the image should be created from.
# This parameter is required for non marketplace images.
${ImagePath},
Expand All @@ -118,7 +119,7 @@ function New-AzStackHCIVMImage{
[Parameter(ParameterSetName='Marketplace', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Body')]
[System.String]
# The name of the marketplace gallery image definition offer.
# The name of the marketplae gallery image definition offer.
${Offer},

[Parameter(ParameterSetName='Marketplace', Mandatory)]
Expand Down Expand Up @@ -238,6 +239,8 @@ function New-AzStackHCIVMImage{
${ProxyUseDefaultCredentials}

)
$testPlayback = $false
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } }

if (-Not ($name -match $imageNameRegex )) {
Write-Error "Invalid Name for image provided: $name" -ErrorAction Stop
Expand Down Expand Up @@ -307,7 +310,9 @@ function New-AzStackHCIVMImage{
$PSBoundParameters['ErrorAction'] = 'Stop'
try {
Az.StackHCIVM.internal\New-AzStackHCIVMMarketplaceGalleryImage @PSBoundParameters
Start-Sleep -Seconds 60
if (-not $testPlayback) {
Start-Sleep -Seconds 60
}
$PercentCompleted = 0
Write-Progress -Activity "Download Percentage: " -Status "$PercentCompleted % Complete:" -PercentComplete $PercentCompleted
$null = $PSBoundParameters.Remove("Version")
Expand All @@ -330,15 +335,16 @@ function New-AzStackHCIVMImage{
$PercentCompleted = 0
}
Write-Progress -Activity "Download Percentage: " -Status "$PercentCompleted % Complete" -PercentComplete $PercentCompleted
Start-Sleep -Seconds 5
if (-not $testPlayback) {
Start-Sleep -Seconds 5
}
if ($image.ProvisioningStatus -eq "Failed") {
Break
}
}
if ($image.ProvisioningStatus -eq "Failed"){
Write-Error $image.StatusErrorMessage -ErrorAction Stop
}

} catch {
$e = $_
if ($e.FullyQualifiedErrorId -match "MissingAzureKubernetesMapping" ){
Expand Down Expand Up @@ -416,6 +422,9 @@ function New-AzStackHCIVMImage{
if ($PSCmdlet.ParameterSetName -eq "GalleryImage")
{
try{
$null = $PSBoundParameters.Remove("ImagePath")
$SecureImagePath = ConvertTo-SecureString -String $ImagePath -AsPlainText -Force
$PSBoundParameters.Add('ImagePath', $SecureImagePath)
Az.StackHCIVM.internal\New-AzStackHCIVMGalleryImage -ErrorAction Stop @PSBoundParameters
} catch {
$e = $_
Expand Down
12,668 changes: 12,568 additions & 100 deletions src/StackHCIVM/StackHCIVM.Autorest/test/AzStackHCIVMImageNew.Recording.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ Describe 'AzStackHCIVMImageNew' {
It 'Create Image ' {
New-AzStackHCIVMImage -Name $env.imageName -ImagePath $env.imagePath -SubscriptionId $env.newSubscriptionId -ResourceGroupName $env.newResourceGroupName -CustomLocationId $env.newCustomLocationId -Location $env.location -OSType $env.osTypeLinux | Select-Object -Property ProvisioningState | Should -BeExactly "@{ProvisioningState=Succeeded}"
}
It 'Create MarketplaceImage'
{
It 'Create MarketplaceImage' {
New-AzStackHCIVMImage -Name $env.mkpImageName -Offer $env.offer -Publisher $env.publisher -Sku $env.sku -Version $env.version -SubscriptionId $env.newSubscriptionId -ResourceGroupName $env.newResourceGroupName -CustomLocationId $env.newCustomLocationId -Location $env.location -OSType $env.osTypeWindows
$image = Get-AzStackHCIVMImage -ResourceId "/subscriptions/37908b1f-2848-4c85-b8bf-a2cab2c3b0ba/resourceGroups/mkclus90-rg/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/testMkpImage1"
$image = Get-AzStackHCIVMImage -ResourceId "/subscriptions/$($env.newSubscriptionId)/resourceGroups/$($env.newResourceGroupName)/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/$($env.mkpImageName)"
$image.ProvisioningState | Should -BeExactly "Succeeded"
}

Expand Down

Large diffs are not rendered by default.

Loading