Skip to content

Migrate Compute from generation to main #24631

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

Merged
merged 4 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
598 changes: 594 additions & 4 deletions src/Compute/Compute.Autorest/Az.Compute.format.ps1xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Compute/Compute.Autorest/Az.Compute.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.Compute.private.dll'
FormatsToProcess = './Az.Compute.format.ps1xml'
FunctionsToExport = 'Get-AzGalleryApplication', 'Get-AzGalleryApplicationVersion', 'New-AzGalleryApplication', 'New-AzGalleryApplicationVersion', 'Remove-AzGalleryApplication', 'Remove-AzGalleryApplicationVersion', 'Remove-AzVMRunCommand', 'Remove-AzVmssVMRunCommand', 'Set-AzVMRunCommand', 'Set-AzVmssVMRunCommand', 'Update-AzGalleryApplication', 'Update-AzGalleryApplicationVersion', '*'
FunctionsToExport = 'Get-AzGalleryApplication', 'Get-AzGalleryApplicationVersion', 'Invoke-AzSpotPlacementRecommender', 'New-AzGalleryApplication', 'New-AzGalleryApplicationVersion', 'Remove-AzGalleryApplication', 'Remove-AzGalleryApplicationVersion', 'Remove-AzVMRunCommand', 'Remove-AzVmssVMRunCommand', 'Set-AzVMRunCommand', 'Set-AzVmssVMRunCommand', 'Update-AzGalleryApplication', 'Update-AzGalleryApplicationVersion', '*'
AliasesToExport = '*'
PrivateData = @{
PSData = @{
Expand Down
24 changes: 14 additions & 10 deletions src/Compute/Compute.Autorest/Az.Compute.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,41 @@

# Ask for the shared functionality table
$VTable = Register-AzModule

# Tweaks the pipeline on module load
$instance.OnModuleLoad = $VTable.OnModuleLoad

# Following two delegates are added for telemetry
$instance.GetTelemetryId = $VTable.GetTelemetryId
$instance.Telemetry = $VTable.Telemetry


# Delegate to sanitize the output object
$instance.SanitizeOutput = $VTable.SanitizerHandler

# Delegate to get the telemetry info
$instance.GetTelemetryInfo = $VTable.GetTelemetryInfo

# Tweaks the pipeline per call
$instance.OnNewRequest = $VTable.OnNewRequest

# Gets shared parameter values
$instance.GetParameterValue = $VTable.GetParameterValue

# Allows shared module to listen to events from this module
$instance.EventListener = $VTable.EventListener

# Gets shared argument completers
$instance.ArgumentCompleter = $VTable.ArgumentCompleter

# The name of the currently selected Azure profile
$instance.ProfileName = $VTable.ProfileName


# Load the custom module
$customModulePath = Join-Path $PSScriptRoot './custom/Az.Compute.custom.psm1'
if(Test-Path $customModulePath) {
$null = Import-Module -Name $customModulePath
}

# Export nothing to clear implicit exports
Export-ModuleMember

Expand All @@ -97,12 +101,12 @@
# Load the last folder if no profile is selected
$profileDirectory = $directories | Select-Object -Last 1
}

if($profileDirectory) {
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
$exportsPath = $profileDirectory.FullName
}

if($exportsPath) {
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath
Expand Down
32 changes: 31 additions & 1 deletion src/Compute/Compute.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For information on how to develop for `Az.Compute`, see [how-to.md](how-to.md).
### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
commit: 1a925d1afe288a5f20d078bbc89214a36a0e4287
commit: 77c47a7fba8d8b900595966b81d6bb92a0308370
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
Expand All @@ -35,6 +35,7 @@ input-file:
- $(repo)/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-01-03/gallery.json
- $(repo)/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2023-07-01/runCommand.json
- $(repo)/specification/compute/resource-manager/Microsoft.Compute/common-types/v1/common.json
- $(repo)/specification/compute/resource-manager/Microsoft.Compute/DiagnosticRP/preview/2024-03-01-preview/diagnostic.json
# If the swagger has not been put in the repo, you may uncomment the following line and refer to it locally
module-version: 0.3.0
# Normally, title is the service name
Expand Down Expand Up @@ -232,4 +233,33 @@ directive:
subject: VMRunCommand|VmssVMRunCommand
verb: Get
remove: true
### Remove All Diagnostic cmdlets aside from Invoke Spot Placement Recommender - generate ONLY SpotPlacementRecommender cmdlets
- where:
verb: Get
subject: Diagnostic
remove: true
- where:
verb: Get
subject: DiskInspection
remove: true
- where:
verb: New
subject: DiskInspection
remove: true
- where:
verb: Read
subject: DiagnosticOperation
remove: true
- where:
verb: Register
subject: DiskInspectionStorageConfiguration
remove: true
- where:
verb: Test
subject: DiskInspectionStorageConfiguration
remove: true
- where:
verb: Get
subject: SpotPlacementRecommender
remove: true
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"resourceType": "locations",
"apiVersion": "2024-03-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.compute"
},
"commands": [
{
"name": "Invoke-AzSpotPlacementRecommender",
"description": "Generates placement scores for Spot VM skus.",
"path": "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/diagnostics/spotPlacementRecommender/generate",
"help": {
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.compute/invoke-azspotplacementrecommender"
},
"parameterSets": [
{
"parameters": [
"-Location <String>",
"[-SubscriptionId <String>]"
]
}
]
},
"examples": [
{
"description": "Generates placement scores for Spot VM skus.",
"parameters": [
{
"name": "-Location",
"value": "[Path.location]"
},
{
"name": "-SubscriptionId",
"value": "[Path.subscriptionId]"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
### Example 1: Regionally scoped Spot Placement Recommender scores
```powershell
$resourceSku1 = @{sku = "Standard_D2_v3"}
$resourceSku2 = @{sku = "Standard_D2_v2"}
$resourceSku3 = @{sku = "Standard_D4_v3"}
$desiredSizes = $resourceSku1,$resourceSku2,$resourceSku3
$desiredLocations = 'japaneast','southcentralus','centralus'

$response = Invoke-AzSpotPlacementRecommender -Location eastus -DesiredCount 1 -DesiredLocation $desiredLocations -DesiredSize $desiredSizes
$response.PlacementScore
```

```output
AvailabilityZone IsQuotaAvailable Region Score Sku
---------------- ---------------- ------ ----- ---
True japaneast RestrictedSkuNotAvailable Standard_D2_v3
True japaneast RestrictedSkuNotAvailable Standard_D2_v2
True japaneast RestrictedSkuNotAvailable Standard_D4_v3
True southcentralus High Standard_D2_v3
True southcentralus High Standard_D2_v2
True southcentralus High Standard_D4_v3
True centralus RestrictedSkuNotAvailable Standard_D2_v3
True centralus RestrictedSkuNotAvailable Standard_D2_v2
True centralus RestrictedSkuNotAvailable Standard_D4_v3
```

Returns regionally scoped spot placement recommender scores for the input.

### Example 2: Zonally scoped Spot Placement Recommender scores
```powershell
$resourceSku1 = @{sku = "Standard_D2_v3"}
$resourceSku2 = @{sku = "Standard_D2_v2"}
$resourceSku3 = @{sku = "Standard_D4_v3"}
$desiredSizes = $resourceSku1,$resourceSku2,$resourceSku3
$desiredLocations = 'japaneast','southcentralus','centralus'

$response = Invoke-AzSpotPlacementRecommender -Location eastus -DesiredCount 1 -DesiredLocation $desiredLocations -DesiredSize $desiredSizes -AvailabilityZone
$response.PlacementScore
```

```output
AvailabilityZone IsQuotaAvailable Region Score Sku
---------------- ---------------- ------ ----- ---
1 True japaneast High Standard_D2_v3
2 True japaneast High Standard_D2_v3
3 True japaneast High Standard_D2_v3
1 True japaneast High Standard_D2_v2
2 True japaneast High Standard_D2_v2
3 True japaneast High Standard_D2_v2
1 True japaneast High Standard_D4_v3
2 True japaneast High Standard_D4_v3
3 True japaneast High Standard_D4_v3
1 True southcentralus High Standard_D2_v3
2 True southcentralus High Standard_D2_v3
3 True southcentralus High Standard_D2_v3
1 True southcentralus High Standard_D2_v2
2 True southcentralus High Standard_D2_v2
3 True southcentralus High Standard_D2_v2
1 True southcentralus High Standard_D4_v3
2 True southcentralus High Standard_D4_v3
3 True southcentralus High Standard_D4_v3
1 True centralus DataNotFoundOrStale Standard_D2_v3
2 True centralus High Standard_D2_v3
3 True centralus High Standard_D2_v3
1 True centralus DataNotFoundOrStale Standard_D2_v2
2 True centralus High Standard_D2_v2
3 True centralus High Standard_D2_v2
1 True centralus DataNotFoundOrStale Standard_D4_v3
2 True centralus High Standard_D4_v3
3 True centralus High Standard_D4_v3
```

Returns zonally scoped spot placement recommender scores for the input.

### Example 3: Regionally scoped Spot Placement Recommender scores using SpotPlacementRecommenderInput parameter as argument
```powershell
$resourceSku1 = @{sku = "Standard_D2_v3"}
$resourceSku2 = @{sku = "Standard_D2_v2"}
$resourceSku3 = @{sku = "Standard_D4_v3"}
$desiredSizes = $resourceSku1,$resourceSku2,$resourceSku3
$desiredLocations = 'japaneast','southcentralus','centralus'
$desiredCount = 1

$spotPlacementRecommenderInput = @{desiredLocation = $desiredLocations; desiredSize = $desiredSizes; desiredCount = $desiredCount; availabilityZone = $false}

$response = Invoke-AzSpotPlacementRecommender -Location eastus -SpotPlacementRecommenderInput $spotPlacementRecommenderInput
$response.PlacementScore
```

```output
AvailabilityZone IsQuotaAvailable Region Score Sku
---------------- ---------------- ------ ----- ---
True japaneast RestrictedSkuNotAvailable Standard_D2_v3
True japaneast RestrictedSkuNotAvailable Standard_D2_v2
True japaneast RestrictedSkuNotAvailable Standard_D4_v3
True southcentralus High Standard_D2_v3
True southcentralus High Standard_D2_v2
True southcentralus High Standard_D4_v3
True centralus RestrictedSkuNotAvailable Standard_D2_v3
True centralus RestrictedSkuNotAvailable Standard_D2_v2
True centralus RestrictedSkuNotAvailable Standard_D4_v3
```

Returns regionally scoped spot placement recommender scores for the input.

### Example 2: Zonally scoped Spot Placement Recommender scores using SpotPlacementRecommenderInput parameter as argument
```powershell
$resourceSku1 = @{sku = "Standard_D2_v3"}
$resourceSku2 = @{sku = "Standard_D2_v2"}
$resourceSku3 = @{sku = "Standard_D4_v3"}
$desiredSizes = $resourceSku1,$resourceSku2,$resourceSku3
$desiredLocations = 'japaneast','southcentralus','centralus'
$desiredCount = 1

$spotPlacementRecommenderInput = @{desiredLocation = $desiredLocations; desiredSize = $desiredSizes; desiredCount = $desiredCount; availabilityZone = $true}

$response = Invoke-AzSpotPlacementRecommender -Location eastus -SpotPlacementRecommenderInput $spotPlacementRecommenderInput
$response.PlacementScore
```

```output
AvailabilityZone IsQuotaAvailable Region Score Sku
---------------- ---------------- ------ ----- ---
1 True japaneast High Standard_D2_v3
2 True japaneast High Standard_D2_v3
3 True japaneast High Standard_D2_v3
1 True japaneast High Standard_D2_v2
2 True japaneast High Standard_D2_v2
3 True japaneast High Standard_D2_v2
1 True japaneast High Standard_D4_v3
2 True japaneast High Standard_D4_v3
3 True japaneast High Standard_D4_v3
1 True southcentralus High Standard_D2_v3
2 True southcentralus High Standard_D2_v3
3 True southcentralus High Standard_D2_v3
1 True southcentralus High Standard_D2_v2
2 True southcentralus High Standard_D2_v2
3 True southcentralus High Standard_D2_v2
1 True southcentralus High Standard_D4_v3
2 True southcentralus High Standard_D4_v3
3 True southcentralus High Standard_D4_v3
1 True centralus High Standard_D2_v3
2 True centralus High Standard_D2_v3
3 True centralus High Standard_D2_v3
1 True centralus High Standard_D2_v2
2 True centralus High Standard_D2_v2
3 True centralus High Standard_D2_v2
1 True centralus High Standard_D4_v3
2 True centralus High Standard_D4_v3
3 True centralus High Standard_D4_v3
```

Returns zonally scoped spot placement recommender scores for the input.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ INPUTOBJECT <IComputeIdentity>: Identity Parameter
[Id <String>]: Resource identity path
[InstanceId <String>]: The instance ID of the virtual machine.
[Location <String>]: The location upon which run commands is queried.
[OperationId <String>]: The ID of an ongoing async operation.
[ResourceGroupName <String>]: The name of the resource group.
[RunCommandName <String>]: The name of the virtual machine run command.
[SubscriptionId <String>]: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
Expand Down Expand Up @@ -172,7 +173,13 @@ begin {
List = 'Az.Compute.private\Get-AzGalleryApplication_List';
}
if (('Get', 'List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
$testPlayback = $false
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } }
if ($testPlayback) {
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
} else {
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
}
}
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ INPUTOBJECT <IComputeIdentity>: Identity Parameter
[Id <String>]: Resource identity path
[InstanceId <String>]: The instance ID of the virtual machine.
[Location <String>]: The location upon which run commands is queried.
[OperationId <String>]: The ID of an ongoing async operation.
[ResourceGroupName <String>]: The name of the resource group.
[RunCommandName <String>]: The name of the virtual machine run command.
[SubscriptionId <String>]: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
Expand Down Expand Up @@ -187,7 +188,13 @@ begin {
List = 'Az.Compute.private\Get-AzGalleryApplicationVersion_List';
}
if (('Get', 'List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) {
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
$testPlayback = $false
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } }
if ($testPlayback) {
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
} else {
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
}
}
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
Expand Down
Loading