How do I create an Azure Log Analytics Workspace?
In this guide, we will create an Azure Log Analytics Workspace using Pulumi. Log Analytics Workspace is a central repository that provides insights into the operations of your cloud environment.
Key Points
- We will define a resource group to contain the Log Analytics Workspace.
- We will create a Log Analytics Workspace within the resource group.
- The workspace will be configured with a specific location and retention period.
Code
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";
// Create a resource group
const resourceGroup = new azure.resources.ResourceGroup("resourceGroup", {
resourceGroupName: "myResourceGroup",
location: "WestEurope",
});
// Create a Log Analytics Workspace
const logAnalyticsWorkspace = new azure.operationalinsights.Workspace("logAnalyticsWorkspace", {
resourceGroupName: resourceGroup.name,
workspaceName: "myLogAnalyticsWorkspace",
location: resourceGroup.location,
sku: {
name: "PerGB2018",
},
retentionInDays: 30,
features: {
enableLogAccessUsingOnlyResourcePermissions: true,
},
});
// Export the Workspace ID
export const workspaceId = logAnalyticsWorkspace.id;
Summary
In this guide, we created an Azure Log Analytics Workspace using Pulumi. We started by creating a resource group, then created a Log Analytics Workspace within that resource group. The workspace was configured with a specific SKU and retention period. Finally, we exported the workspace ID for reference.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.