How to find and remove inactive users after a while automatically in Azure Portal

Aldair de Brito Vicente 21 Reputation points
2022-09-21T20:46:39.773+00:00

Hi folks!
I would like to ask for help. In my company we use Azure Cloud Services (DevOps, Portal, etc). For intern reasons, we need to remove users (send to trash is enough) after 45 days of inactivity, in other words, users that not logged-in in the past 45 days on Azure DevOps. I searched a lot online and tried some things throw Portal (using Logic Apps, for example) but was unsuccessful. So, that's the logic that we have:

Once a week, an auto routine scan the users list on Azure Portal and, if their last login on Azure DevOps was 45 days ago, send them to the trash.

That's it. But we couldn't find anyway to do this.
Best regards,
Aldair

Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Luke Murray 11,436 Reputation points MVP Volunteer Moderator
    2022-09-22T20:45:40.853+00:00

    You could use an Azure Automation account or Azure function (or Azure Logic App) to do what you want.

    Look at those solutions to run on a schedule, for example an Azure Automation powershell runbook with a weekly schedule, that checks Azure AD, and then the Azure DevOps API, then emails a report - or delete it.

    https://learn.microsoft.com/en-us/azure/automation/overview
    https://learn.microsoft.com/en-us/rest/api/azure/devops/account/?view=azure-devops-rest-7.1
    https://learn.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0

    If your users are accessing Azure DevOps through Azure AD group membership - take a look at Access Review, before you look at creating a custom solution: https://learn.microsoft.com/en-us/azure/active-directory/privileged-identity-management/pim-create-azure-ad-roles-and-resource-roles-review

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Takahito Iwasa 4,851 Reputation points MVP Volunteer Moderator
    2022-09-21T21:38:00.2+00:00

    Hi, @AldairdeBritoVicente-2217

    but was unsuccessful

    How did the logic you created fail?
    It's better to have specific discussions that focus on your logic problems

    Or you can look for another approach.

    For example, if your retirement date is federated in Azure AD P2, you can use lifecycle workflows to automate the offboarding process.

    https://learn.microsoft.com/en-us/azure/active-directory/governance/create-lifecycle-workflow


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.