Question regarding powershell script.

Jawed, Altamash 0 Reputation points
2023-12-06T19:56:18.67+00:00

I prepared a powershell script which will fetch the list the resources created on azure in last 30 days.

Get-AzLog -StartTime (Get-Date).AddDays(-30) -EndTime (Get-Date) -Status "Succeeded"

`

| Where-Object { $.ResourceGroupName -ne "" -and $.OperationName -like " *Create *"
*
I just wanted to confirm if any resources created in azure then in activity logs, is it always an operationName logs will be generated which must contains create word in their operation name.

E.g.

For storage account created OperationName is like "Update Storage Account Create"
For VM created OperationName is like "Create or Update Virtual Machine"

So, for this two we have create word somwhere in operationname.

Can I be sure that if I create any resources in azure it must conatins word create

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,878 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue-MSFT 40,901 Reputation points Microsoft External Staff
    2023-12-07T09:07:33.9133333+00:00

    Hello Jawed,

    If we see the operations of Azure resources, the create and update will be both under operation of "write" for most of the resources: https://learn.microsoft.com/en-us/azure/role-based-access-control/resource-provider-operations. In this case, filtering "create" in operation names may have exact results of updating resources.

    Per the document for schema of activity logs: https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/activity-log-schema#administrative-category, we can see the creation of resources should be under administrative catogery. Checking into the properties, we may use httpRequest or subStatus as reference as these properties could indicate the HTTP opeation "PUT" or "201 Created":

    User's image

    User's image

    However, there are various of kinds of Azure resources. Some of them may have their own log schema. You will always need to check per resource type before you can confirm the query you used can apply expectedly.

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

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.