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

Error with polling from NewSubnetInjection.ps1 script #619

Open
ArmaanMcleod opened this issue Aug 3, 2024 · 1 comment
Open

Error with polling from NewSubnetInjection.ps1 script #619

ArmaanMcleod opened this issue Aug 3, 2024 · 1 comment

Comments

@ArmaanMcleod
Copy link

When choosing to poll with NewSubnetInjection.ps1, there is a failure when converting operational Location to a string.

.\NewSubnetInjection.ps1

cmdlet NewSubnetInjection at command pipeline position 1
Supply values for the following parameters:
environmentId: 00000000-0000-0000-0000-000000000000
policyArmId: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/enterprise-policy-rg/providers/Microsoft.PowerPlatform/enterprisePolicies/power-apps-dev-test-enterprise-policy
Logging In...
Logged In...
Environment reterieved

Enterprise Policy reterieved

WARNING: Resulting JSON is truncated as serialization has exceeded the set depth of 2.
Linking of vnet policy started for environement 00000000-0000-0000-0000-000000000000
Do you want to poll the linking operation (y/n)
y
Polling the link operation every 5 seconds.
InvokeApi: C:\Users\Armaan\Documents\github-repos\PowerApps-Samples\powershell\enterprisePolicies\Common\EnvironmentOperations.ps1:105
Line |
 105 |          $pollResult = InvokeApi -Method GET -Route $operationLink
     |                                                     ~~~~~~~~~~~~~~
     | Cannot process argument transformation on parameter 'Route'. Cannot convert value to type System.String.
Operation polling failed
InvalidOperation: C:\Users\Armaan\Documents\github-repos\PowerApps-Samples\powershell\enterprisePolicies\Common\EnvironmentOperations.ps1:114
Line |
 114 |          if ($operationState.Equals("Failed") -or $operationState.Equa|              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.
@ArmaanMcleod
Copy link
Author

Looks like below lines:

$operationLocation = $headers.'operation-location'
$retryAfter = $headers.'Retry-After'

return an array of one string when -Route is expecting just a singular string.

Getting first item seems to fix it:

$operationLocation = $headers['operation-location'][0]
$retryAfter = $headers['Retry-After'][0]

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

2 participants