When working with multiple organizations and their Azure estates, draconian application of policies dictating user behaviors can quite quickly become an annoyance. Among the first of these experienced on a new account is often the Azure Portal inactivity timer. Whilst it’s entirely understandable to limit the exposure of an authorized Azure Portal browser tab for most users, experienced admins will balk at having each of their many tabs automatically signed out as they work on complex tasks.
For those of us that inevitably spawn several Portal tabs whilst working, this can be exasperating and there’s often no easy way to work around it. Whilst there’s an option in the Portal preferences to “override” the imposed timeout, this often merely lets you shorten it!

Each time this triggers, you are unceremoniously signed out and confronted with a round of MFA-enforced sign-ins which typically have to be done for each tab. But worst of all, anything you were working on – whether it’s a view you curated to inspect some infrastructure, or a multi-page resource creation you were stepping through – is instantly lost.
The Solution
To combat this frustration and help prevent it building up into outright rage, I put together a simple but effective userscript you can add to your browser. It tries to kep you signed in by watching out for the warning toast ,and simulates dismissing it, thus postponing the inevitable session expiry indefinitely!
At the time of writing, the implementation looks something like this:
var azurePortalInactivityKludgeId
addEventListener("visibilitychange", (event) => {
if (document.hidden) {
azurePortalInactivityKludgeId = window.setInterval(tryToStaySignedIn, 10000)
} else {
window.clearInterval(tryToStaySignedIn)
}
});
function tryToStaySignedIn() {
staySignedInButton = document.querySelector('div.fxs-button[title="Do not sign out"]')
if (staySignedInButton !== null) {
staySignedInButton.click();
}
}
How it works should be fairly straightforward to parse even if you don’t know much Javascript (like me). When the document visibility changes, such as moving to another tab, minimizing, or switching to another app/window, a function will run every 10 seconds to look for the dreaded sign-out warning toast. If found, it will “click” the Do not sign out
button.
How to Install
You’ll first need a userscript manager extension for your browser, if it doesn’t support userscripts natively. I suggest Violentmonkey, an open source userscript manager for Firefox, Edge, and Chrome (and probably derivatives).
Once you have a userscript manager installed, head over to my repository manicminer/userscripts on GitHub where you can inspect the source for yourself and install it by browsing directly to the latest version.