How can we improve the Azure Resource Manager?

how to identify who created the virtual machine or any other resources under our subscription

We have a subscription. Most of my team members are admins. We are trying to clean up the resources by decommissioning the unused resources. For this, we need to know as to who created these resources so that we can directly connect with them. Is there any way?

115 votes
Sign in
(thinking…)
Sign in with: Microsoft
Signed in as (Sign out)

We’ll send you updates on this idea

Qamar Qazi shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

15 comments

Sign in
(thinking…)
Sign in with: Microsoft
Signed in as (Sign out)
Submitting...
  • Roopa commented  ·   ·  Flag as inappropriate

    Activity Log or any log is not the write approach to know who has created thsi resource.. It is difficult and close to impossible to know who has create this resource.
    What is the reason to not to have such a simple and yet critical feature to know the "created by" and "timestamp"?

  • Daniel Tipser commented  ·   ·  Flag as inappropriate

    It would be nice if the creator of the resource (Virtual Machine) is keep forever, not to be depending on a Log, and hence a date.

  • Ganesh Majeti commented  ·   ·  Flag as inappropriate

    Why is there no action on this feedback since long? I see bunch of tickets duplicated to one another by Ryan.. but no program manager seem to be taking this feedback seriously

  • Solution Guy commented  ·   ·  Flag as inappropriate

    $logFile = ".\tagging_log.txt";
    $createdByLabel = "CreatedBy";

    #Connect-AzureRmAccount

    #Select-AzureRmSubscription XXXXXXXXX

    function log
    {
    param ([string]$message)
    $timestamp = Get-Date -Format o;
    $completeMessage = -Join($timestamp, ": ", $message);
    Write-Host $completeMessage;
    Add-Content -Path $logFile -Value $completeMessage;
    }

    function setTag
    {
    param ([string]$caller, $vM)
    log -message (" Adding " + $createdByLabel + " tag, value: " + $caller);

    $newTags = $vM.Tags + @{ $createdByLabel = $caller };
    #Set-AzureRmResource -Tag $newTags -ResourceId $vM.Id -Force;
    }

    $vMs = Get-AzureRmVM;

    foreach ($vM in $vMs)
    {
    log -message ("Resource Group: " + $vM.ResourceGroupName + " | VM Name: " + $vM.Name);

    if ($vM.Tags.Keys -contains $createdByLabel)
    {
    $createdBy = $vMs.Tags | Where-Object -Property $createdByLabel;
    log -message (" " + $createdBy.Keys + ": " + $createdBy.Values);
    }
    else
    {
    log -message " No CreatedBy Tag";
    $events = Get-AzureRmLog -ResourceGroupName $vM.ResourceGroupName -WarningAction SilentlyContinue | Where-Object ResourceId -EQ $vM.Id | Sort-Object -Property EventTimestamp;
    if ($events.Count -gt 0)
    {
    $location = 0;
    $entityOnly = $true;
    foreach($event in $events)
    {
    if($event[$location].Caller -like "*@*")
    {
    setTag -caller $events[$location].Caller -vM $vM;
    $entityOnly = $false;
    break;
    }
    }

    #foreach($event in $events)
    #{
    # log -message ("CALLER:" + $event.Caller);
    #}

    if ($entityOnly -eq $true)
    {
    log -message " Human creator not available, going with entity...";
    setTag -caller $events[0].Caller -vM $vM;
    }
    }
    else
    {
    log -message " No creator information available...";
    setTag -caller "Unknown" -vM $vM;
    }
    }
    }

    if ($Error.Count -ne 0)
    {
    log -message "There was one or more errors...";

    foreach ($iError in $Error)
    {
    log -message ("Error: " + $iError);
    }
    }
    log -message "Complete";

  • Ed Draper commented  ·   ·  Flag as inappropriate

    Same here... I have a big mess that I need to clean up. I'm surprised that this data isn't readily available.

  • Brandon R Barnett commented  ·   ·  Flag as inappropriate

    We're doing the same thing -- would love to send out an inventory to clean up resources but I don't know who created which resources

Feedback and Knowledge Base