Workspace Management¶
Log Analytics workspace operations determine where Azure Monitor Logs land, how long they stay available, and who can safely query or change the environment. This runbook focuses on repeatable day-2 workspace administration with Azure CLI.
flowchart TD
Sources[Azure resources and agents] --> Workspace[Log Analytics workspace]
Workspace --> Retention[Retention and daily cap]
Workspace --> Access[RBAC and query access]
Workspace --> Network[Private or public ingestion settings]
Workspace --> Recovery[Soft-delete and recovery workflow] Prerequisites¶
- Azure CLI authenticated with
az login. - A resource group for the monitoring platform.
- Permissions:
Log Analytics Contributorto create or modify workspaces.Monitoring Contributorfor related Azure Monitor operations.User Access Administratorif you also assign RBAC.
- Shell variables prepared for copy-paste examples:
When to Use¶
- You need to create a new production or non-production workspace.
- You need to adjust retention, daily cap, or pricing settings after cost review.
- You need to validate workspace features before onboarding more data sources.
- You need to review access boundaries before delegating operational ownership.
- You need to recover from accidental deletion or configuration drift.
Procedure¶
Step 1: Inspect the current workspace inventory¶
Start by confirming whether a workspace already exists and which operational settings are currently applied.
az monitor log-analytics workspace list \
--resource-group $RG \
--query "[].{name:name,location:location,sku:sku.name,retention:retentionInDays,publicNetworkAccessForIngestion:publicNetworkAccessForIngestion}" \
--output table
Name Location Sku Retention PublicNetworkAccessForIngestion
--------------- ---------- -------- ----------- --------------------------------
law-ops-central eastus PerGB2018 30 Enabled
Step 2: Create or standardize the workspace baseline¶
Create the workspace with an explicit region and then confirm the immutable identifiers that downstream configurations depend on.
az monitor log-analytics workspace create \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--location $LOCATION \
--output json
{
"customerId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"features": {
"enableLogAccessUsingOnlyResourcePermissions": true
},
"id": "/subscriptions/<subscription-id>/resourceGroups/rg-monitoring-prod/providers/Microsoft.OperationalInsights/workspaces/law-ops-central",
"location": "eastus",
"name": "law-ops-central",
"provisioningState": "Succeeded",
"retentionInDays": 30,
"sku": {
"name": "PerGB2018"
}
}
az monitor log-analytics workspace show \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--query "{id:id,customerId:customerId,provisioningState:provisioningState}" \
--output json
{
"customerId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"id": "/subscriptions/<subscription-id>/resourceGroups/rg-monitoring-prod/providers/Microsoft.OperationalInsights/workspaces/law-ops-central",
"provisioningState": "Succeeded"
}
Step 3: Configure retention and daily cap guardrails¶
Microsoft Learn recommends tuning retention and ingestion controls according to compliance and cost objectives instead of leaving defaults unchanged.
az monitor log-analytics workspace update \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--retention-time 90 \
--quota 25 \
--output json
{
"name": "law-ops-central",
"retentionInDays": 90,
"sku": {
"name": "PerGB2018"
},
"workspaceCapping": {
"dailyQuotaGb": 25.0,
"dataIngestionStatus": "RespectQuota"
}
}
az monitor log-analytics workspace show \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--query "{retention:retentionInDays,dailyCap:workspaceCapping.dailyQuotaGb,ingestionStatus:workspaceCapping.dataIngestionStatus}" \
--output json
Step 4: Review access mode and operational permissions¶
Workspace operations frequently fail because access is configured for the wrong audience. Validate feature flags first, then inspect RBAC assignments.
az monitor log-analytics workspace show \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--query "{resourcePermissions:features.enableLogAccessUsingOnlyResourcePermissions,publicQueryAccess:publicNetworkAccessForQuery,publicIngestionAccess:publicNetworkAccessForIngestion}" \
--output json
az role assignment list \
--scope $WORKSPACE_ID \
--query "[].{principalName:principalName,role:roleDefinitionName,principalType:principalType}" \
--output table
PrincipalName Role PrincipalType
-------------------------- -------------------------- -------------
monitoring-ops-admins Log Analytics Contributor Group
platform-readers Log Analytics Reader Group
automation-monitoring-spn Monitoring Contributor ServicePrincipal
Step 5: Validate workspace health and ingestion readiness¶
Before onboarding new resources, verify that the workspace responds to metadata queries and returns usage data.
az monitor log-analytics workspace table list \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--query "[0:5].{name:name,plan:plan,retentionInDays:retentionInDays}" \
--output table
Name Plan RetentionInDays
------------------ ------------ ---------------
Heartbeat Analytics 90
Perf Analytics 90
Usage Analytics 90
AzureActivity Analytics 90
AzureMetrics Analytics 90
Use a query against the workspace to confirm that billable usage or heartbeat data is visible.
az monitor log-analytics query \
--workspace $WORKSPACE_ID \
--analytics-query "Usage | where TimeGenerated > ago(1d) | summarize TotalGB=sum(Quantity)/1024 by DataType | top 5 by TotalGB desc" \
--output table
Verification¶
Confirm that the workspace exists with the expected baseline:
az monitor log-analytics workspace show \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--query "{name:name,location:location,retention:retentionInDays,sku:sku.name,provisioningState:provisioningState}" \
--output json
{
"location": "eastus",
"name": "law-ops-central",
"provisioningState": "Succeeded",
"retention": 90,
"sku": "PerGB2018"
}
az monitor log-analytics workspace show \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--query "{dailyCap:workspaceCapping.dailyQuotaGb,queryAccess:publicNetworkAccessForQuery,ingestionAccess:publicNetworkAccessForIngestion}" \
--output json
Rollback / Troubleshooting¶
If retention or daily cap changes cause operational issues, revert them explicitly:
az monitor log-analytics workspace update \
--resource-group $RG \
--workspace-name $WORKSPACE_NAME \
--retention-time 30 \
--quota -1 \
--output json
az monitor log-analytics workspace list-deleted-workspaces \
--resource-group $RG \
--query "[].{name:name,location:location,deletedDate:deletedDate}" \
--output table
Name Location DeletedDate
--------------- ---------- -------------------------
law-ops-central eastus 2026-04-05T09:10:12.000Z
AuthorizationFailed - Confirm workspace scope RBAC rather than only resource-group inheritance assumptions. - RegionNotSupported - Create the workspace in a region supported by the intended Azure Monitor feature. - Queries return no data - Check whether diagnostic settings, DCR associations, or agents are actually sending data. - Daily cap reached - Increase quota temporarily or reduce noisy tables before business-critical data is lost. Automation¶
Workspace administration is a good candidate for scheduled governance checks. Use automation to detect drift in retention, cap, access mode, and role assignments.
Example shell automation:
az monitor log-analytics workspace list \
--query "[].{name:name,id:id,retention:retentionInDays,dailyCap:workspaceCapping.dailyQuotaGb}" \
--output json
Usage table. See Also¶
Sources¶
- Microsoft Learn: Create a Log Analytics workspace in Azure Monitor
- Microsoft Learn: Manage access to Log Analytics workspaces
- Microsoft Learn: Manage usage and costs with Azure Monitor Logs
- Microsoft Learn: Set daily cap on a Log Analytics workspace
- Microsoft Learn: Azure Monitor Logs best practices