getting storage account File Share Count metric in File metric namespace using az cli

frigo 1 Reputation point
2025-04-24T07:39:58.5066667+00:00

I would like to use the az cli to retrieve the "File Share Count" metric from the "File" namespace of my storage account. This is available in the Azure portal, however I did not find a way to access this metric using the az cli:

az monitor metrics list-namespaces --resource /subscriptions/14../resourceGroups/nld11/providers/Microsoft.Storage/storageAccounts/..f4 -o table This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus Classification Metric Namespace Name


Platform microsoft.storage/storageaccounts

there is no "File" namespace and no metric matching a File Share Count.

Is there a way to retrieve the File Share Count metric value through the az cli?

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,410 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Nandamuri Pranay Teja 2,495 Reputation points Microsoft External Staff Moderator
    2025-04-24T08:21:35.59+00:00

    Hello frigo,

    Thanks for your question!

    Use az monitor metrics list-definitions with the Microsoft.Storage/storageAccounts namespace and --metric-names FileShareCount to confirm the metric's existence. Post which Uses az monitor metrics list with the same namespace and --metric "FileShareCount" to retrieve the current value.

    Please be informed that While the File namespace doesn't directly expose a "File Share Count" metric, the Microsoft.Storage/storageAccounts namespace does contain this information. You can retrieve the definition of the FileShareCount metric using the following command:

    az monitor metrics list-definitions --resource /subscriptions/14../resourceGroups/nld11/providers/Microsoft.Storage/storageAccounts/..f4 --namespace Microsoft.Storage/storageAccounts --metric-names FileShareCount -o table
    

    After confirming the definition of the metric, you may obtain the current value by utilizing the az monitor metrics list command.

    az monitor metrics list --resource /subscriptions/14../resourceGroups/nld11/providers/Microsoft.Storage/storageAccounts/..f4 --namespace Microsoft.Storage/storageAccounts --metric "FileShareCount" -o table
    

    This command will output the current count of file shares within your specified storage account.

    Hope the above answer helps! Please let us know do you have any further queries.


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members. 


  2. Venkatesan S 2,260 Reputation points Microsoft External Staff Moderator
    2025-04-28T11:06:21.8966667+00:00

    Hi @frigo

    You can use the below Azure CLI command to get the Filesharecount metrics.

    Command:

    az monitor metrics list --resource "/subscriptions/xxxxx/resourceGroups/xxxx/providers/Microsoft.Storage/storageAccounts/xxxxx/fileServices/default" --metric "FileShareCount" --namespace "Microsoft.Storage/storageAccounts/fileServices" --interval PT1H --aggregation Average
    

    In resource you need to "/subscriptions/xxxxxxx/resourceGroups/xxx/providers/Microsoft.Storage/storageAccounts/venkat326123/fileServices/default" for file service.

    Output:

    venkxxxxn [ ~ ]$ az monitor metrics list --resource "/subscriptions/xxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Storage/storageAccounts/venkat326123/fileServices/default" --metric "FileShareCount" --namespace "Microsoft.Storage/storageAccounts/fileServices" --interval PT1H --aggregation Average
    {
      "cost": 59,
      "interval": "PT1H",
      "namespace": "Microsoft.Storage/storageAccounts/fileServices",
      "resourceregion": "eastus",
      "timespan": "2025-04-28T09:27:32Z/2025-04-28T10:27:32Z",
      "value": [
        {
          "displayDescription": "The number of file shares in the storage account.",
          "errorCode": "Success",
          "id": "/subscriptions/xxxxxxxx/resourceGroups/xxxxx/providers/Microsoft.Storage/storageAccounts/venkat326123/fileServices/default/providers/Microsoft.Insights/metrics/FileShareCount",
          "name": {
            "localizedValue": "File Share Count",
            "value": "FileShareCount"
          },
          "resourceGroup": "venkatesan-rg",
          "timeseries": [
            {
              "data": [
                {
                  "average": 3.0,
                  "timeStamp": "2025-04-28T09:27:00Z"
                }
              ],
              "metadatavalues": []
            }
          ],
          "type": "Microsoft.Insights/metrics",
          "unit": "Count"
        }
      ]
    }
    

    enter image description here

    Portal:image

    Hope this answer helps! please let us know if you have any further queries. I’m happy to assist you further.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    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.