Azure / Azure/azure-powershell
The Resource under resource group was not found
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
When running
`Get-AzApplicationGatewayFirewallPolicy `
I get:
`The Resource 'Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/' under resource group '' was not found.`
I have checked that I'm looking in the right subscription and have set the context explicitly but to no avail. I only have a **Reader** role but from my understanding permissions should be the same for the portal and PS and I can see the WAF policy in the portal.
Any ideas?
### Issue script & Debug output
```PowerShell
PS C:\Program Files\PowerShell\7> $AppGwFirewallPolicy = Get-AzApplicationGatewayFirewallPolicy -Name "" -ResourceGroupName ""
DEBUG: 08:58:33 - GetAzureApplicationGatewayFirewallPolicyCommand begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 08:58:33 - using account id ''...
DEBUG: [Common.Authentication]: Authenticating using Account: '', environment: 'AzureCloud', tenant: ''
DEBUG: 08:58:33 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:''
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33] Found 1 cache accounts and 0 broker accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33] Returning 1 accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] MSAL MSAL.NetCore with assembly version '4.30.1.0'. CorrelationId(185159cd-cc44-4832-9376-71c433d0268d)
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] === AcquireTokenSilent Parameters ===
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] LoginHint provided: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] Account provided: True
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] ForceRefresh: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 185159cd-cc44-4832-9376-71c433d0268d
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] === Token Acquisition (SilentRequest) started:
Authority Host: login.microsoftonline.com
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] Access token is not expired. Returning the found cache entry. [Current time (05/10/2022 06:58:33) - Expiration Time (05/10/2022 08:12:02 +00:00) - Extended Expiration Time (05/10/2022 08:12:02 +00:00)]
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] Returning access token found in cache. RefreshOn exists ? False
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] Fetched access token from host login.microsoftonline.com.
DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19044 [05/10/2022 06:58:33 - ] === Token Acquisition finished successfully. An access token was returned with Expiration Time: 05/10/2022 08:12:02 +00:00 and Scopes https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2022-05-10T08:12:02.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '', UserId: ''
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/?api-version=2021-05-01
Headers:
x-ms-client-request-id : 5b0c1b96-a0ae-472e-babd-47f4e44371c2
Accept-Language : en-US
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
NotFound
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-failure-cause : gateway
x-ms-request-id : 3f8032ca-ec18-47ba-9431-0c0c39629e3f
x-ms-correlation-request-id : 3f8032ca-ec18-47ba-9431-0c0c39629e3f
x-ms-routing-request-id : FRANCESOUTH:20220510T065833Z:3f8032ca-ec18-47ba-9431-0c0c39629e3f
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Date : Tue, 10 May 2022 06:58:33 GMT
Body:
{
"error": {
"code": "ResourceNotFound",
"message": "The Resource 'Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/' under resource group '' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
}
}
Get-AzApplicationGatewayFirewallPolicy: The Resource 'Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/' under resource group '' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
DEBUG: AzureQoSEvent: Module: Az.Network:4.16.1; CommandName: Get-AzApplicationGatewayFirewallPolicy; PSVersion: 7.2.3; IsSuccess: False; Duration: 00:00:00.7885961; Exception: The Resource 'Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/' under resource group '' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix;
DEBUG: Finish sending metric.
DEBUG: 08:58:35 - GetAzureApplicationGatewayFirewallPolicyCommand end processing.
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.2.3
PSEdition Core
GitCommitId 7.2.3
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.7.6 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount…}
Script 4.16.1 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzApplicationGatewayBackendAddressPool, Add-AzApplicationGatewayBackendHttpSetting, …
Script 5.6.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}
```
### Error output
```PowerShell
Resolve-AzError
DEBUG: 09:03:31 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 09:03:31 - using account id ''...
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release. Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.
HistoryId: 1
RequestId : 3f8032ca-ec18-47ba-9431-0c0c39629e3f
Message : The Resource 'Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/' under resource group '' was not found. For more details please go to
https://aka.ms/ARMResourceNotFoundFix
ServerMessage : ResourceNotFound: The Resource 'Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/' under resource group '' was not found. For more details
please go to https://aka.ms/ARMResourceNotFoundFix (System.Collections.Generic.List`1[Microsoft.Rest.Azure.CloudError])
ServerResponse : {NotFound}
RequestMessage : {GET https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies
/?api-version=2021-05-01}
InvocationInfo : {Get-AzApplicationGatewayFirewallPolicy}
Line : $AppGwFirewallPolicy = Get-AzApplicationGatewayFirewallPolicy -Name "" -ResourceGroupName ""
Position : At line:1 char:24
+ … allPolicy = Get-AzApplicationGatewayFirewallPolicy -Name "…
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
StackTrace : at Microsoft.Azure.Management.Network.WebApplicationFirewallPoliciesOperations.GetWithHttpMessagesAsync(String resourceGroupName, String policyName, Dictionary`2 customHeaders,
CancellationToken cancellationToken)
at Microsoft.Azure.Management.Network.WebApplicationFirewallPoliciesOperationsExtensions.GetAsync(IWebApplicationFirewallPoliciesOperations operations, String resourceGroupName, String
policyName, CancellationToken cancellationToken)
at Microsoft.Azure.Management.Network.WebApplicationFirewallPoliciesOperationsExtensions.Get(IWebApplicationFirewallPoliciesOperations operations, String resourceGroupName, String
policyName)
at Microsoft.Azure.Commands.Network.ApplicationGatewayFirewallPolicyBaseCmdlet.GetApplicationGatewayFirewallPolicy(String resourceGroupName, String name)
at Microsoft.Azure.Commands.Network.GetAzureApplicationGatewayFirewallPolicyCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
HistoryId : 1
The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
DEBUG: AzureQoSEvent: Module: Az.Accounts:2.7.6; CommandName: Resolve-AzError; PSVersion: 7.2.3; IsSuccess: True; Duration: 00:00:04.1351129
DEBUG: Finish sending metric.
DEBUG: 09:03:36 - ResolveError end processing.
```
Contributor guide
Research direction
Start with Get-AzApplicationGatewayFirewallPolicy and reproduce the request using the reported Az.Network 4.16.1 environment. Compare the subscription, resource group, policy name, and resource visible in the portal with the exact request URI; done means the cmdlet resolves the existing policy or the issue documents a confirmed service or permission mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100