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

Azure Gov: Get-AzPolicySetDefinition Not Working #25474

Closed
tbisque opened this issue Jul 8, 2024 · 2 comments
Closed

Azure Gov: Get-AzPolicySetDefinition Not Working #25474

tbisque opened this issue Jul 8, 2024 · 2 comments
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Policy Azure Resource Policy

Comments

@tbisque
Copy link

tbisque commented Jul 8, 2024

Description

In AzureUSGovernment environments, Get-AzPolicySetDefinition returns:

The resource type 'policySetDefinitions' could not be found in the namespace 'Microsoft.Authorization' for api version '2023-04-01'. The supported api-versions are '2017-06-01-preview,2018-03-01,2018-05-01,2019-01-01,2019-06-01,2019-09-01,2020-03-01,2020-08-01,2020-09-01,2021-06-01'.

Issue script & Debug output

Get-AzPolicySetDefinition                                                           
DEBUG: 2:37:55 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].
DEBUG: 2:37:55 PM - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 2:37:55 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 2:37:55 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].
DEBUG: 2:37:55 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 2:37:55 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 2:37:55 PM - GetAzureRMContextCommand end processing.
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing: 
DEBUG: CmdletProcessRecordStart: 
DEBUG: CmdletGetPipeline: 
DEBUG: CmdletBeforeAPICall: 
DEBUG: URLCreated: /subscriptions/________-____-____-____-____________/providers/Microsoft.Authorization/policySetDefinitions?api-version=2023-04-01
DEBUG: RequestCreated: /subscriptions/________-____-____-____-____________/providers/Microsoft.Authorization/policySetDefinitions?api-version=2023-04-01
DEBUG: HeaderParametersAdded: 
DEBUG: 2:37:55 PM - [ConfigManager] Got nothing from [DisableInstanceDiscovery], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.usgovcloudapi.net/subscriptions/________-____-____-____-____________/providers/Microsoft.Authorization/policySetDefinitions?api-version=2023-04-01

Headers:
x-ms-unique-id                : 5
x-ms-client-request-id        : fab6792e-1b64-4a38-a812-d5a526bc630a
CommandName                   : &
FullCommandName               : Get-AzPolicySetDefinition_List
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v12.0.0,PSVersion/v7.4.3,Az.Policy/7.1.0

Body:



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

Status Code:
NotFound

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
x-ms-failure-cause            : gateway
x-ms-request-id               : 987cbf64-5383-4990-82e7-6533f7d2cdee
x-ms-correlation-request-id   : 987cbf64-5383-4990-82e7-6533f7d2cdee
x-ms-routing-request-id       : USDODEAST:20240708T143755Z:987cbf64-5383-4990-82e7-6533f7d2cdee
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Date                          : Mon, 08 Jul 2024 14:37:54 GMT

Body:
{
  "error": {
    "code": "InvalidResourceType",
    "message": "The resource type 'policySetDefinitions' could not be found in the namespace 'Microsoft.Authorization' for api version '2023-04-01'. The supported api-versions are '2017-06-01-preview,2018-03-01,2018-05-01,2019-01-01,2019-06-01,2019-09-01,2020-03-01,2020-08-01,2020-09-01,2021-06-01'."
  }
}


DEBUG: ResponseCreated: 
DEBUG: BeforeResponseDispatch: 
DEBUG: CmdletProcessRecordEnd: 
Get-AzPolicySetDefinition_List: /usr/local/share/powershell/Modules/Az.Resources/7.1.0/Policy.Autorest/custom/Get-AzPolicySetDefinition.ps1:269
Line |
 269 |      $scriptCmd = {& $wrappedCmd @PSBoundParameters}
     |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The resource type 'policySetDefinitions' could not be found in the namespace 'Microsoft.Authorization' for api version '2023-04-01'. The supported api-versions are
     | '2017-06-01-preview,2018-03-01,2018-05-01,2019-01-01,2019-06-01,2019-09-01,2020-03-01,2020-08-01,2020-09-01,2021-06-01'.

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.3
PSEdition                      Core
GitCommitId                    7.4.3
OS                             CBL-Mariner/Linux
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     3.0.0                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     8.0.0                 Az.Compute                          {Add-AzImageDataDisk, Add-AzVhd, Add-AzVMAdditionalUnattendContent, Add-AzVMDataDisk…}
Script     7.6.0                 Az.Network                          {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzApplicationGatewayBackendAddressPool, Add-AzApplicationGat…
Script     7.1.0                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}
Script     7.0.0                 Az.Storage                          {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountManagementPolicyAction, Add-AzStorageAccountNetworkRule, Clo…
Script     1.1.3                 Az.Tools.Predictor                  {Disable-AzPredictor, Enable-AzPredictor, Open-AzPredictorSurvey, Send-AzPredictorRating}

Error output

DEBUG: 3:10:17 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].
DEBUG: 3:10:17 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 3:10:17 PM - using account id 'MSI@50342'...
DEBUG: 3:10:17 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 3:10:17 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].

   HistoryId: 2

Message        : [InvalidResourceType] : The resource type 'policySetDefinitions' could not be found in the namespace 'Microsoft.Authorization' for api version '2023-04-01'. The 
                 supported api-versions are '2017-06-01-preview,2018-03-01,2018-05-01,2019-01-01,2019-06-01,2019-09-01,2020-03-01,2020-08-01,2020-09-01,2021-06-01'.
StackTrace     : 
Exception      : System.Exception
InvocationInfo : {Get-AzPolicySetDefinition_List}
Line           :     $scriptCmd = {& $wrappedCmd @PSBoundParameters}
                 
Position       : At /usr/local/share/powershell/Modules/Az.Resources/7.1.0/Policy.Autorest/custom/Get-AzPolicySetDefinition.ps1:269 char:19
                 +     $scriptCmd = {& $wrappedCmd @PSBoundParameters}
                 +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 2



DEBUG: 3:10:17 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 3:10:17 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent:  Module: Az.Accounts:3.0.0; CommandName: Resolve-AzError; PSVersion: 7.4.3; IsSuccess: True; Duration: 00:00:00.0203502; SanitizeDuration: 00:00:00.0010256
DEBUG: 3:10:17 PM - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = [].
DEBUG: 3:10:17 PM - ResolveError end processing.
@tbisque tbisque added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jul 8, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jul 8, 2024
@mentat9
Copy link
Member

mentat9 commented Jul 17, 2024

This is now fixed: the new API version is rolled out: please retry. IMPORTANT: it will only work from a clean shell. The same issue will continue to repro in any shell that loaded the Az.Resources/Az.Accounts modules prior to the new API version rollout.

@isra-fel
Copy link
Member

Thanks for @mentat9 's follow up!
Closing as dup of #25483

@isra-fel isra-fel added Policy Azure Resource Policy and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Policy Azure Resource Policy
Projects
None yet
Development

No branches or pull requests

3 participants