web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Automation of Post Env...
Finance forum

Automation of Post Environment Refresh Actions

(0) ShareShare
ReportReport
Posted on by

Question: Is there any option to automatically kick off an X++ job (or any automated task) after a sandbox refresh?

Info on Current Sandbox Refresh

This article explains how refreshes work for cloud hosted (sandbox) environments: https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/database/database-refresh

It points out that the refresh will:

- Disable all users other than admin

- Disable all batch jobs

Another side effect is where you use accounts specific to an environment those accounts are overwritten by the refresh, so need to be recreated.  E.g. we connect to our environments via OData, and use different accounts for accessing production and test to help silo the environments / reduce the risk of accidentally connecting a test system to production or vice versa, and thus creating an issue; so after a refresh we have to replace `interfaceAccountProd@example.com` with `interfaceAccountNonProd@example.com`.  

Info on Automation

It looks like Raphael Taglilani's done some work towards automating post-refresh tasks: blog.zealots.solar

He provides SQL and PowerShell scripts for this.  Most of the focus is on refresh non-sandbox environments from the refreshed sandbox; but there are some other post-refresh bits (e.g. enabling all users).

Sadly running such scripts still needs to be run manually.

What would be excellent is if there were some event driven process such that once a refresh completes successfully a job can be fired off to perform a series of tasks.  For most use-cases I'd assume this would include:

- Enabling all users (or a specific subset, say all users with the `system administrator` role / all users listed in a resource file)

- Putting all withheld batch jobs back to waiting status

- Amending any external email addresses to dummy ones (e.g. so tests don't accidentally fire off invoices to external customers) / any other data masking activities.

However the key point is how you detect that the refresh has occurred / completed before triggering the scripts to correct the data.

Thoughts

A hacky approach which may work would be to have a scheduled task run on the VM every 5 minutes and run a query which signals this change (i.e. for my use case we could look at the interface account ; when we see the production account in a test environment that triggers our other scripts to connect to the database and update the data).  A more generic approach may be to check for a change of GlobalGuid; though it looks like that may no longer be used (i.e. https://tenant.sandbox.operations.dynamics.com/?cmp=DAT&mi=SysTableBrowser&TableName=SYSSQMSETTINGS shows this field still exists, but returns no records).

However, this frequent polling approach has a bad smell to it.  Is there a better way?

Thanks in advance for all thoughts & feedback.

I have the same question (0)
  • Community Member Profile Picture
    on at

    Note: It seems others are looking for an LCS API.  If something like that existed, depending on features, it may give options to resolve the above requirement.

    If others are also keen for an LCS API, please vote: experience.dynamics.com/.../idea

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    305,643 Super User 2026 Season 1 on at

    Hi John,

    As workaround, you can use Microsoft Flow with some actions to be performed. For all changes you want to apply, you need to find public data entities which can actually update the data. For sure, it would be possible to enable users. Once you get a notification that the environment is ready, you can check it and then run the Flow (e.g. using a button on your mobile device).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans