Skip to content

Fix missing deleteReason parameter in Env Request Cleanup flow#10667

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-cleanup-flow-error
Closed

Fix missing deleteReason parameter in Env Request Cleanup flow#10667
Copilot wants to merge 2 commits intomainfrom
copilot/fix-cleanup-flow-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 7, 2026

The "Env Request | Cleanup" flow fails when deleting expired environments with error: "The delete reason was null or invalid."

Power Platform Admin API version 2022-05-01 requires a deleteReason parameter when calling Remove-AdminEnvironment, but the flow was not providing it.

Changes

  • Added deleteReason: "Expiration" parameter to the Delete_expired_Environment action in EnvRequestCleanup-E1C9B288-F98C-EB11-A812-000D3A1F6A72.json
"parameters": {
  "environment": "@item()?['_coe_environment_value']",
  "api-version": "2022-05-01",
  "deleteReason": "Expiration"
}

Other workflows using older API versions (2018-10-01, 2021-04-01) are unaffected as the parameter is not required in those versions.

Original prompt

This section details on the original issue you should resolve

<issue_title>[CoE Starter Kit - BUG] Env Request | Cleanup flow cannot run properly</issue_title>
<issue_description>### Does this bug already exist in our backlog?

  • I have checked and confirm this is a new bug.

Describe the issue

The flow will error at the "Delete Expired Environment" with the following error message.

Action 'Delete_expired_Environment' failed: The delete reason was null or invalid. Valid values are: User, Tenant, Expiration, LinkedResourceDeleted, Manual, CommonDataServiceMigration, Application, Service, TeamDeleted, ConnectedGroupDeleted, CreateFailed, InactivityThreshold, DeletedByTenantPolicyEvaluation, InconsistencyDetection

I had one environment that a user set to expire and the flow will not delete the environment, I have since then excused that app, but the flow keeps failing on that environment.

I did create a test environment to see if something was just wrong with that particular environment but I got the same error message.

Expected Behavior

The flow will automatically delete environments that are set to expire.

What solution are you experiencing the issue with?

Core

What solution version are you using?

4.50.7

What app or flow are you having the issue with?

Env Request | Cleanup

What method are you using to get inventory and telemetry?

Cloud flows

Steps To Reproduce

No response

Anything else?

No response</issue_description>

<agent_instructions>Analyze and troubleshoot the issue why Env Request | Cleanup flow cannot run properly and provide the solution for this issue</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Custom agent used: CoE Custom Agent
Specialized agent for triaging and fixing issues in the CoE Starter Kit. Always consult the official CoE docs and the team’s SharePoint notes first, then mine prior GitHub issues and the CoE Common Responses playbook.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

The Power Platform Admin API version 2022-05-01 requires a deleteReason parameter when deleting environments. This fix adds the "Expiration" reason to the Delete_expired_Environment action, which resolves the error: "The delete reason was null or invalid."

Co-authored-by: AmarSaiRam <220305901+AmarSaiRam@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix cleanup flow to handle expired environment deletion Fix missing deleteReason parameter in Env Request Cleanup flow Jan 7, 2026
Copilot AI requested a review from AmarSaiRam January 7, 2026 05:32
@AmarSaiRam AmarSaiRam closed this Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CoE Starter Kit - BUG] Env Request | Cleanup flow cannot run properly

2 participants