You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running the CreateSubnetInjectionEnterprisePolicy.ps1 script, I got an error on line 32 stating the resource group wasn't found. After confirming I had input the correct name, I reviewed the code and found that the context appears to be incorrect. I believe the issue is that my default subscription is different than the one I'm running this script against, and the call to the New-AzResourceGroupDeployment commandlet on line 32 of this included script is running against the wrong subscription. To confirm this, I added Set-AzContext -Subscription $subscriptionId just before line 32, added $subscriptionId as an additional parameter to this function, and changed line 86 of CreateSubnetInjectionEnterprisePolicy.ps1 to $result = PutEnterprisePolicy $subscriptionId $resourceGroup $body. This resulted in the policy getting created and the script completing without errors.
Here's an example of what the execution, with errors, looks like:
`PS C:\PowerApps-Samples\powershell\enterprisePolicies\SubnetInjection> .\CreateSubnetInjectionEnterprisePolicy.ps1
cmdlet CreateSubnetInjectionEnterprisePolicy at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
subscriptionId: abcd1234-ab12-ab12-ab12-abcdef123456
resourceGroup: Networking-RG
enterprisePolicyName: PowerPlatformSubnetInjection
enterprisePolicylocation: unitedstates
primaryVnetId: /subscriptions/abcd1234-ab12-ab12-ab12-abcdef123456/resourceGroups/Networking-RG/providers/Microsoft.Network/virtualNetworks/vNet-Primary
primarySubnetName: PowerPlatformIntegration
secondaryVnetId: /subscriptions/abcd1234-ab12-ab12-ab12-abcdef123456/resourceGroups/Networking-RG/providers/Microsoft.Network/virtualNetworks/vNet-Secondary
secondarySubnetName: PowerPlatformIntegration
Logging In...
Logged In...
Creating Enterprise policy...
New-AzResourceGroupDeployment: C:\PowerApps-Samples\powershell\enterprisePolicies\Common\EnterprisePolicyOperations.ps1:32
Line |
32 | … $policy = New-AzResourceGroupDeployment -DeploymentName "EPDeployme …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 11:31:22 AM - Error: Code=ResourceGroupNotFound; Message=Resource group 'Networking-RG' could not be found.
New-AzResourceGroupDeployment: C:\PowerApps-Samples\powershell\enterprisePolicies\Common\EnterprisePolicyOperations.ps1:32
Line |
32 | … $policy = New-AzResourceGroupDeployment -DeploymentName "EPDeployme …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The deployment validation failed
InvalidOperation: C:\PowerApps-Samples\powershell\enterprisePolicies\Common\EnterprisePolicyOperations.ps1:35
Line |
35 | if ($policy.ProvisioningState.Equals("Succeeded"))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| You cannot call a method on a null-valued expression.
Error creating/updating Enterprise policy
Subnet Injection Enterprise policy not created`
The text was updated successfully, but these errors were encountered:
PowerApps-Samples/powershell/enterprisePolicies/Common/EnterprisePolicyOperations.ps1
Line 32 in ed3b866
When running the CreateSubnetInjectionEnterprisePolicy.ps1 script, I got an error on line 32 stating the resource group wasn't found. After confirming I had input the correct name, I reviewed the code and found that the context appears to be incorrect. I believe the issue is that my default subscription is different than the one I'm running this script against, and the call to the New-AzResourceGroupDeployment commandlet on line 32 of this included script is running against the wrong subscription. To confirm this, I added
Set-AzContext -Subscription $subscriptionId
just before line 32, added $subscriptionId as an additional parameter to this function, and changed line 86 of CreateSubnetInjectionEnterprisePolicy.ps1 to$result = PutEnterprisePolicy $subscriptionId $resourceGroup $body
. This resulted in the policy getting created and the script completing without errors.Here's an example of what the execution, with errors, looks like:
`PS C:\PowerApps-Samples\powershell\enterprisePolicies\SubnetInjection> .\CreateSubnetInjectionEnterprisePolicy.ps1
cmdlet CreateSubnetInjectionEnterprisePolicy at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
subscriptionId: abcd1234-ab12-ab12-ab12-abcdef123456
resourceGroup: Networking-RG
enterprisePolicyName: PowerPlatformSubnetInjection
enterprisePolicylocation: unitedstates
primaryVnetId: /subscriptions/abcd1234-ab12-ab12-ab12-abcdef123456/resourceGroups/Networking-RG/providers/Microsoft.Network/virtualNetworks/vNet-Primary
primarySubnetName: PowerPlatformIntegration
secondaryVnetId: /subscriptions/abcd1234-ab12-ab12-ab12-abcdef123456/resourceGroups/Networking-RG/providers/Microsoft.Network/virtualNetworks/vNet-Secondary
secondarySubnetName: PowerPlatformIntegration
Logging In...
Logged In...
Creating Enterprise policy...
New-AzResourceGroupDeployment: C:\PowerApps-Samples\powershell\enterprisePolicies\Common\EnterprisePolicyOperations.ps1:32
Line |
32 | … $policy = New-AzResourceGroupDeployment -DeploymentName "EPDeployme …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 11:31:22 AM - Error: Code=ResourceGroupNotFound; Message=Resource group 'Networking-RG' could not be found.
New-AzResourceGroupDeployment: C:\PowerApps-Samples\powershell\enterprisePolicies\Common\EnterprisePolicyOperations.ps1:32
Line |
32 | … $policy = New-AzResourceGroupDeployment -DeploymentName "EPDeployme …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The deployment validation failed
InvalidOperation: C:\PowerApps-Samples\powershell\enterprisePolicies\Common\EnterprisePolicyOperations.ps1:35
Line |
35 | if ($policy.ProvisioningState.Equals("Succeeded"))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| You cannot call a method on a null-valued expression.
Error creating/updating Enterprise policy
Subnet Injection Enterprise policy not created`
The text was updated successfully, but these errors were encountered: