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

Get-AzureRmRoleAssignment (AzureRM.Resources 6.0.2) doesn't respect -ErrorAction #8235

Closed
acmcg opened this issue Jan 4, 2019 · 2 comments
Closed
Assignees

Comments

@acmcg
Copy link

acmcg commented Jan 4, 2019

Description

Get-AzureRmRoleAssignment (AzureRM.Resources 6.0.2) doesn't respect -ErrorAction

Script/Steps for Reproduction

Note: Commands are being run against AzureStack

Run the commandlet against a non existent policy assignment with ErrorAction set to SilentlyContinue
get-AzureRmPolicyAssignment -Name "BogusPolicyAssignment" -Scope "/subscriptions/$SubscriptionId/resourceGroups/$resourceGroup" -ErrorAction SilentlyContinue

Module Version

Get-Module -Name AzureRM.Resources  -ListAvailable

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.0.2      AzureRM.Resources                   {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment...}

Environment Data

Name                           Value
----                           -----
PSVersion                      5.1.17134.407
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.407
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Debug Output

DEBUG: 5:01:43 PM - GetAzurePolicyAssignmentCmdlet begin processing with ParameterSet 'GetPolicyAssignmentName'.
DEBUG: 5:01:43 PM - using account id '[email protected]'...
DEBUG: [Common.Authentication]: Authenticating using Account: '[email protected]', environment: 'AzureStackUser', tenant: '62574f56-4554-49e3-9194-34570282a2e3'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/04/2019 06:01:43:  - TokenCache: Serializing token cache with 11 items.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/04/2019 06:01:43:  - TokenCache: Serializing token cache with 11 items.

DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '62574f56-4554-49e3-9194-34570282a2e3', Endpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.azureinfinitis.onmicrosoft.com/3a33850c-fcea-4740-a8fc-320c93d6a190', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/62574f56-4554-49e3-9194-34570282a2e3/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '62574f56-4554-49e3-9194-34570282a2e3', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/04/2019 06:01:43: 59ffada1-907e-4b6a-9eaa-52130a5d60f5 - AcquireTokenHandlerBase: === Token Acquisition started:
        Authority: https://login.microsoftonline.com/62574f56-4554-49e3-9194-34570282a2e3/
        Resource: https://management.azureinfinitis.onmicrosoft.com/3a33850c-fcea-4740-a8fc-320c93d6a190
        ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
        CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (11 items)
        Authentication Target: User


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/04/2019 06:01:43:  - TokenCache: Deserialized 11 items to token cache.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 01/04/2019 06:01:43: 59ffada1-907e-4b6a-9eaa-52130a5d60f5 - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/04/2019 06:01:43: 59ffada1-907e-4b6a-9eaa-52130a5d60f5 - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 01/04/2019 06:01:43: 59ffada1-907e-4b6a-9eaa-52130a5d60f5 - TokenCache: 19.56329442 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/04/2019 06:01:43: 59ffada1-907e-4b6a-9eaa-52130a5d60f5 - TokenCache: A matching item (access token or refresh token or both) was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/04/2019 06:01:43: 59ffada1-907e-4b6a-9eaa-52130a5d60f5 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
        Access Token Hash: QuqPRvewwUcd66hpEMCjOKJFKR33AHQxfeHREUx1jiQ=
        Refresh Token Hash: 0+YOEXBl6aYftB7jNlz6eQj07qszmv57SpBw9lkErJU=
        Expiration Time: 01/04/2019 06:21:17 +00:00
        User Hash: DWrZjkZUKOwxdVEaCFZiby5AlEPTT3pfQ+1uXWofbdo=


DEBUG: [Common.Authentication]: Received token with LoginType 'LiveId', Tenant: '62574f56-4554-49e3-9194-34570282a2e3', UserId: '[email protected]'
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '01/04/2019 06:21:17 +00:00', MultipleResource? 'True', Tenant: '62574f56-4554-49e3-9194-34570282a2e3', UserId: '[email protected]'
DEBUG: [Common.Authentication]: User info for token DisplayId: '[email protected]', Name: Andrew McGregor, IdProvider: 'https://sts.windows.net/62574f56-4554-49e3-9194-34570282a2e3/', Uid: 'd750a276-4907-47a1-bc8b-fbc64c7d9f84'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '01/04/2019 06:21:17 +00:00' Comparing to '01/04/2019 06:01:43 +00:00' With threshold '00:05:00', calculated time until token
expiry: '00:19:33.7966654'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.equinix.vigilant.it/subscriptions/a5bd5d47-8056-47ed-be92-2f53401c709f/resourceGroups/bu1-nprod-pcs-equinix-audit/providers/Microsoft.Authorization/policyassignments/RestrictLocationsRG?api-version=2017-06-01-preview

Headers:
User-Agent                    : PSVersion/v1.10.2,AzurePowershell/v6.9.0
ParameterSetName              : GetPolicyAssignmentName
CommandName                   : Get-AzureRmPolicyAssignment

Body:



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

Status Code:
NotFound

Headers:
Pragma                        : no-cache
x-ms-request-id               : equinix:7258550a-83d1-4098-a3ad-79f405a933f3
x-ms-ratelimit-remaining-subscription-reads: 14936
x-ms-correlation-request-id   : 8664fdd8-e0a3-4ae2-989c-ac11939e31dc
x-ms-routing-request-id       : EQUINIX:20190104T060143Z:8664fdd8-e0a3-4ae2-989c-ac11939e31dc
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Fri, 04 Jan 2019 06:01:43 GMT

Body:
{
  "error": {
    "code": "PolicyAssignmentNotFound",
    "message": "The policy assignment 'RestrictLocationsRG' is not found."
  }
}


get-AzureRmPolicyAssignment : PolicyAssignmentNotFound : The policy assignment 'RestrictLocationsRG' is not found.
At line:1 char:1
+ get-AzureRmPolicyAssignment -Name $policy.assignmentName -Scope "/sub ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureRmPolicyAssignment], ErrorResponseMessageException
    + FullyQualifiedErrorId : PolicyAssignmentNotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzurePolicyAssignmentCmdlet
@bganapa
Copy link
Member

bganapa commented Feb 6, 2019

Reopening, It is AZURESTACK specific version. The issue is fixed in the latest az module, AZURESTACK version still has this issue. I will see what we could do here in the next release

@maddieclayton maddieclayton removed this from the 2019-02-12 milestone Feb 7, 2019
@bganapa
Copy link
Member

bganapa commented Jun 3, 2019

This is fixed in AzureRm.Resources 6.4.3

@bganapa bganapa closed this as completed Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants