Azure / Azure/azure-powershell
Unable to set CapacityReservation SKU and SkuCapacity parameter for Operational Insights Workspace
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
New-AzOperationalInsightsWorkspace reports "New-AzOperationalInsightsWorkspace: Failed to set Capacity for SKU: CapacityReservation, Capacity is only supported for CapacityReservation SKU" when provising both Sku: CapacityReservation and SkuCapacity:100
It appears to be an issue in the logic of parameter check [here](https://github.com/Azure/azure-powershell/blob/main/src/OperationalInsights/OperationalInsights/Models/PSWorkspaceSku.cs#L80C4-L84C1).
Probably should be **!**serviceTrier.Equals(AllowedWorkspaceServiceTiers.CapacityReservation)
### Issue script & Debug output
```PowerShell
PS /> $DebugPreference='Continue'
PS /> New-AzOperationalInsightsWorkspace -Force -ResourceGroupName: testrg -RetentionInDays: 120 -Location: "East US" -Sku: "CapacityReservation" -Name:"test-law" -SkuCapacity: 100
DEBUG: 3:27:50 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 3:27:50 PM - NewAzureOperationalInsightsWorkspaceCommand begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 3:27:50 PM - using account id '**************'...
DEBUG: 3:27:50 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.OperationalInsights], Cmdlet = [New-AzOperationalInsightsWorkspace]. Returning default value [True].
DEBUG: 3:27:50 PM - [ConfigManager] Got nothing from [EnableErrorRecordsPersistence], Module = [Az.OperationalInsights], Cmdlet = [New-AzOperationalInsightsWorkspace]. Returning default value [False].
New-AzOperationalInsightsWorkspace: Failed to set Capacity for SKU: CapacityReservation, Capacity is only supported for CapacityReservation SKU
DEBUG: 3:27:50 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.OperationalInsights], Cmdlet = [New-AzOperationalInsightsWorkspace]. Returning default value [True].
DEBUG: 3:27:50 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 3:27:50 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 3:27:50 PM - No authentication telemetry is found for the current cmdlet with Id 72b7b4f1-a199-4cac-a271-24a71f55100c.
DEBUG: AzureQoSEvent: Module: Az.OperationalInsights:3.4.1; CommandName: New-AzOperationalInsightsWorkspace; PSVersion: 7.6.5; IsSuccess: False; Duration: 00:00:00.0145902; SanitizeDuration: 00:00:00; Exception: Failed to set Capacity for SKU: CapacityReservation, Capacity is only supported for CapacityReservation SKU;
DEBUG: 3:27:50 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 3:27:50 PM - NewAzureOperationalInsightsWorkspaceCommand end processing.
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.6.5
PSEdition Core
GitCommitId 7.6.5
OS macOS 26.6.2
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 5.5.3 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 3.4.1 Az.OperationalInsights {Disable-AzOperationalInsightsIISLogCollection, Disable-AzOperationalInsightsLinuxCustomLogCollection, Disable-AzOperational…
```
### Error output
```PowerShell
PS /> Resolve-AzError
DEBUG: 3:30:52 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 3:30:52 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 3:30:52 PM - using account id '*********'...
DEBUG: 3:30:52 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Accounts], Cmdlet = [Resolve-AzError]. Returning default value [True].
DEBUG: 3:30:52 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
HistoryId: 21
Message : Failed to set Capacity for SKU: CapacityReservation, Capacity is only supported for CapacityReservation SKU
StackTrace : at Microsoft.Azure.Commands.OperationalInsights.Models.PSWorkspaceSku.ValidateSKU()
at Microsoft.Azure.Commands.OperationalInsights.Models.PSWorkspaceSku..ctor(String name, Nullable`1 capacity)
at Microsoft.Azure.Commands.OperationalInsights.NewAzureOperationalInsightsWorkspaceCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.Management.Automation.PSArgumentException
InvocationInfo : {New-AzOperationalInsightsWorkspace}
Line : New-AzOperationalInsightsWorkspace -Force -ResourceGroupName: testrg -RetentionInDays: 120 -Location: "East US" -Sku: "CapacityReservation" -Name:"test-law" -SkuCapacity: 100
Position : At line:1 char:1
+ New-AzOperationalInsightsWorkspace -Force -ResourceGroupName: testrg …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 21
```
Contributor guide
Assessment
This issue has not been assessed yet.