diff --git a/.github/workflows/ms.operationalinsights.workspaces.yml b/.github/workflows/ms.operationalinsights.workspaces.yml index 385343f542..1d9d477eea 100644 --- a/.github/workflows/ms.operationalinsights.workspaces.yml +++ b/.github/workflows/ms.operationalinsights.workspaces.yml @@ -106,8 +106,7 @@ jobs: - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' uses: ./.github/actions/templates/validateModuleDeployment with: - templateFilePath: '${{ env.modulePath }}/deploy.bicep' - parameterFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' location: '${{ env.location }}' resourceGroupName: '${{ env.resourceGroupName }}' subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' diff --git a/modules/Microsoft.OperationalInsights/workspaces/.test/common/dependencies.bicep b/modules/Microsoft.OperationalInsights/workspaces/.test/common/dependencies.bicep new file mode 100644 index 0000000000..3ecd0c333d --- /dev/null +++ b/modules/Microsoft.OperationalInsights/workspaces/.test/common/dependencies.bicep @@ -0,0 +1,33 @@ +@description('Optional. The location to deploy to.') +param location string = resourceGroup().location + +@description('Required. The name of the Storage Account to create.') +param storageAccountName string + +@description('Required. The name of the Automation Account to create.') +param automationAccountName string + +resource storageAccount 'Microsoft.Storage/storageAccounts@2022-05-01' = { + name: storageAccountName + location: location + sku: { + name: 'Standard_LRS' + } + kind: 'StorageV2' +} + +resource automationAccount 'Microsoft.Automation/automationAccounts@2021-06-22' = { + name: automationAccountName + location: location + properties: { + sku: { + name: 'Basic' + } + } +} + +@description('The resource ID of the created Storage Account.') +output storageAccountResourceId string = storageAccount.id + +@description('The resource ID of the created Automation Account.') +output automationAccountResourceId string = automationAccount.id diff --git a/modules/Microsoft.OperationalInsights/workspaces/.test/common/deploy.test.bicep b/modules/Microsoft.OperationalInsights/workspaces/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..fe22afa2c3 --- /dev/null +++ b/modules/Microsoft.OperationalInsights/workspaces/.test/common/deploy.test.bicep @@ -0,0 +1,198 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.operationalinsights.workspaces-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to.') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.') +param serviceShort string = 'oiwcom' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +module resourceGroupResources 'dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-paramNested' + params: { + storageAccountName: 'dep<>sa${serviceShort}' + automationAccountName: 'dep-<>-auto-${serviceShort}' + } +} + +// Diagnostics +// =========== +module diagnosticDependencies '../../../../.shared/dependencyConstructs/diagnostic.dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-diagnosticDependencies' + params: { + storageAccountName: 'dep<>diasa${serviceShort}01' + logAnalyticsWorkspaceName: 'dep-<>-law-${serviceShort}' + eventHubNamespaceEventHubName: 'dep-<>-evh-${serviceShort}' + eventHubNamespaceName: 'dep-<>-evhns-${serviceShort}' + location: location + } +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + dailyQuotaGb: 10 + dataSources: [ + { + eventLogName: 'Application' + eventTypes: [ + { + eventType: 'Error' + } + { + eventType: 'Warning' + } + { + eventType: 'Information' + } + ] + kind: 'WindowsEvent' + name: 'applicationEvent' + } + { + counterName: '% Processor Time' + instanceName: '*' + intervalSeconds: 60 + kind: 'WindowsPerformanceCounter' + name: 'windowsPerfCounter1' + objectName: 'Processor' + } + { + kind: 'IISLogs' + name: 'sampleIISLog1' + state: 'OnPremiseEnabled' + } + { + kind: 'LinuxSyslog' + name: 'sampleSyslog1' + syslogName: 'kern' + syslogSeverities: [ + { + severity: 'emerg' + } + { + severity: 'alert' + } + { + severity: 'crit' + } + { + severity: 'err' + } + { + severity: 'warning' + } + ] + } + { + kind: 'LinuxSyslogCollection' + name: 'sampleSyslogCollection1' + state: 'Enabled' + } + { + instanceName: '*' + intervalSeconds: 10 + kind: 'LinuxPerformanceObject' + name: 'sampleLinuxPerf1' + objectName: 'Logical Disk' + syslogSeverities: [ + { + counterName: '% Used Inodes' + } + { + counterName: 'Free Megabytes' + } + { + counterName: '% Used Space' + } + { + counterName: 'Disk Transfers/sec' + } + { + counterName: 'Disk Reads/sec' + } + { + counterName: 'Disk Writes/sec' + } + ] + } + { + kind: 'LinuxPerformanceCollection' + name: 'sampleLinuxPerfCollection1' + state: 'Enabled' + } + ] + diagnosticLogsRetentionInDays: 7 + diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId + diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId + diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId + diagnosticEventHubName: diagnosticDependencies.outputs.eventHubNamespaceEventHubName + gallerySolutions: [ + { + name: 'AzureAutomation' + product: 'OMSGallery' + publisher: 'Microsoft' + } + ] + linkedServices: [ + { + name: 'Automation' + resourceId: resourceGroupResources.outputs.automationAccountResourceId + } + ] + linkedStorageAccounts: [ + { + name: 'Query' + resourceId: resourceGroupResources.outputs.storageAccountResourceId + } + ] + lock: 'CanNotDelete' + publicNetworkAccessForIngestion: 'Disabled' + publicNetworkAccessForQuery: 'Disabled' + savedSearches: [ + { + category: 'VDC Saved Searches' + displayName: 'VMSS Instance Count2' + name: 'VMSSQueries' + query: 'Event | where Source == ServiceFabricNodeBootstrapAgent | summarize AggregatedValue = count() by Computer' + } + ] + storageInsightsConfigs: [ + { + storageAccountId: resourceGroupResources.outputs.storageAccountResourceId + tables: [ + 'LinuxsyslogVer2v0' + 'WADETWEventTable' + 'WADServiceFabric*EventTable' + 'WADWindowsEventLogsTable' + ] + } + ] + useResourcePermissions: true + } +} diff --git a/modules/Microsoft.OperationalInsights/workspaces/.test/min.parameters.json b/modules/Microsoft.OperationalInsights/workspaces/.test/min.parameters.json deleted file mode 100644 index 97fc2fafe4..0000000000 --- a/modules/Microsoft.OperationalInsights/workspaces/.test/min.parameters.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-law-min-001" - } - } -} diff --git a/modules/Microsoft.OperationalInsights/workspaces/.test/min/deploy.test.bicep b/modules/Microsoft.OperationalInsights/workspaces/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..b488dcadd6 --- /dev/null +++ b/modules/Microsoft.OperationalInsights/workspaces/.test/min/deploy.test.bicep @@ -0,0 +1,37 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.operationalinsights.workspaces-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to.') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.') +param serviceShort string = 'oiwmin' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + } +} diff --git a/modules/Microsoft.OperationalInsights/workspaces/.test/parameters.json b/modules/Microsoft.OperationalInsights/workspaces/.test/parameters.json deleted file mode 100644 index 462dcfb561..0000000000 --- a/modules/Microsoft.OperationalInsights/workspaces/.test/parameters.json +++ /dev/null @@ -1,179 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-law-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "publicNetworkAccessForIngestion": { - "value": "Disabled" - }, - "publicNetworkAccessForQuery": { - "value": "Disabled" - }, - "dailyQuotaGb": { - "value": 10 - }, - "storageInsightsConfigs": { - "value": [ - { - "storageAccountId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsalaw001", - "tables": [ - "WADWindowsEventLogsTable", - "WADETWEventTable", - "WADServiceFabric*EventTable", - "LinuxsyslogVer2v0" - ] - } - ] - }, - "linkedServices": { - "value": [ - { - "name": "Automation", - "resourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Automation/automationAccounts/adp-<>-az-aut-x-001" - } - ] - }, - "linkedStorageAccounts": { - "value": [ - { - "name": "Query", - "resourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsalaw001" - } - ] - }, - "savedSearches": { - "value": [ - { - "name": "VMSSQueries", - "displayName": "VMSS Instance Count2", - "category": "VDC Saved Searches", - "query": "Event | where Source == 'ServiceFabricNodeBootstrapAgent' | summarize AggregatedValue = count() by Computer" - } - ] - }, - "dataSources": { - "value": [ - { - "name": "applicationEvent", - "kind": "WindowsEvent", - "eventLogName": "Application", - "eventTypes": [ - { - "eventType": "Error" - }, - { - "eventType": "Warning" - }, - { - "eventType": "Information" - } - ] - }, - { - "name": "windowsPerfCounter1", - "kind": "WindowsPerformanceCounter", - "objectName": "Processor", - "instanceName": "*", - "intervalSeconds": 60, - "counterName": "% Processor Time" - }, - { - "name": "sampleIISLog1", - "kind": "IISLogs", - "state": "OnPremiseEnabled" - }, - { - "name": "sampleSyslog1", - "kind": "LinuxSyslog", - "syslogName": "kern", - "syslogSeverities": [ - { - "severity": "emerg" - }, - { - "severity": "alert" - }, - { - "severity": "crit" - }, - { - "severity": "err" - }, - { - "severity": "warning" - } - ] - }, - { - "name": "sampleSyslogCollection1", - "kind": "LinuxSyslogCollection", - "state": "Enabled" - }, - { - "name": "sampleLinuxPerf1", - "kind": "LinuxPerformanceObject", - "syslogSeverities": [ - { - "counterName": "% Used Inodes" - }, - { - "counterName": "Free Megabytes" - }, - { - "counterName": "% Used Space" - }, - { - "counterName": "Disk Transfers/sec" - }, - { - "counterName": "Disk Reads/sec" - }, - { - "counterName": "Disk Writes/sec" - } - ], - "objectName": "Logical Disk", - "instanceName": "*", - "intervalSeconds": 10 - }, - { - "name": "sampleLinuxPerfCollection1", - "kind": "LinuxPerformanceCollection", - "state": "Enabled" - } - ] - }, - "gallerySolutions": { - "value": [ - { - "name": "AzureAutomation", - "product": "OMSGallery", - "publisher": "Microsoft" - } - ] - }, - "useResourcePermissions": { - "value": true - }, - "diagnosticLogsRetentionInDays": { - "value": 7 - }, - "diagnosticStorageAccountId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001" - }, - "diagnosticWorkspaceId": { - "value": "/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001" - }, - "diagnosticEventHubAuthorizationRuleId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey" - }, - "diagnosticEventHubName": { - "value": "adp-<>-az-evh-x-001" - } - } -} diff --git a/modules/Microsoft.OperationalInsights/workspaces/readme.md b/modules/Microsoft.OperationalInsights/workspaces/readme.md index def067e464..bc8c852378 100644 --- a/modules/Microsoft.OperationalInsights/workspaces/readme.md +++ b/modules/Microsoft.OperationalInsights/workspaces/readme.md @@ -464,7 +464,7 @@ The following module usage examples are retrieved from the content of the files >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Min

+

Example 1: Common

@@ -472,47 +472,10 @@ The following module usage examples are retrieved from the content of the files ```bicep module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Workspaces' - params: { - name: '<>-az-law-min-001' - } -} -``` - -
-

- -

- -via JSON Parameter file - -```json -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-law-min-001" - } - } -} -``` - -
-

- -

Example 2: Parameters

- -
- -via Bicep module - -```bicep -module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Workspaces' + name: '${uniqueString(deployment().name)}-test-oiwcom' params: { // Required parameters - name: '<>-az-law-x-001' + name: '<>oiwcom001' // Non-required parameters dailyQuotaGb: 10 dataSources: [ @@ -605,11 +568,11 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { state: 'Enabled' } ] - diagnosticEventHubAuthorizationRuleId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey' - diagnosticEventHubName: 'adp-<>-az-evh-x-001' + diagnosticEventHubAuthorizationRuleId: '' + diagnosticEventHubName: '' diagnosticLogsRetentionInDays: 7 - diagnosticStorageAccountId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001' - diagnosticWorkspaceId: '/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001' + diagnosticStorageAccountId: '' + diagnosticWorkspaceId: '' gallerySolutions: [ { name: 'AzureAutomation' @@ -620,13 +583,13 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { linkedServices: [ { name: 'Automation' - resourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Automation/automationAccounts/adp-<>-az-aut-x-001' + resourceId: '' } ] linkedStorageAccounts: [ { name: 'Query' - resourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsalaw001' + resourceId: '' } ] lock: 'CanNotDelete' @@ -637,12 +600,12 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { category: 'VDC Saved Searches' displayName: 'VMSS Instance Count2' name: 'VMSSQueries' - query: 'Event | where Source == 'ServiceFabricNodeBootstrapAgent' | summarize AggregatedValue = count() by Computer' + query: 'Event | where Source == ServiceFabricNodeBootstrapAgent | summarize AggregatedValue = count() by Computer' } ] storageInsightsConfigs: [ { - storageAccountId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsalaw001' + storageAccountId: '' tables: [ 'LinuxsyslogVer2v0' 'WADETWEventTable' @@ -670,7 +633,7 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-law-x-001" + "value": "<>oiwcom001" }, // Non-required parameters "dailyQuotaGb": { @@ -769,19 +732,19 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { ] }, "diagnosticEventHubAuthorizationRuleId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey" + "value": "" }, "diagnosticEventHubName": { - "value": "adp-<>-az-evh-x-001" + "value": "" }, "diagnosticLogsRetentionInDays": { "value": 7 }, "diagnosticStorageAccountId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001" + "value": "" }, "diagnosticWorkspaceId": { - "value": "/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001" + "value": "" }, "gallerySolutions": { "value": [ @@ -796,7 +759,7 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { "value": [ { "name": "Automation", - "resourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Automation/automationAccounts/adp-<>-az-aut-x-001" + "resourceId": "" } ] }, @@ -804,7 +767,7 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { "value": [ { "name": "Query", - "resourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsalaw001" + "resourceId": "" } ] }, @@ -823,14 +786,14 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { "category": "VDC Saved Searches", "displayName": "VMSS Instance Count2", "name": "VMSSQueries", - "query": "Event | where Source == 'ServiceFabricNodeBootstrapAgent' | summarize AggregatedValue = count() by Computer" + "query": "Event | where Source == ServiceFabricNodeBootstrapAgent | summarize AggregatedValue = count() by Computer" } ] }, "storageInsightsConfigs": { "value": [ { - "storageAccountId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsalaw001", + "storageAccountId": "", "tables": [ "LinuxsyslogVer2v0", "WADETWEventTable", @@ -849,3 +812,40 @@ module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = {

+ +

Example 2: Min

+ +
+ +via Bicep module + +```bicep +module workspaces './Microsoft.OperationalInsights/workspaces/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-oiwmin' + params: { + name: '<>oiwmin001' + } +} +``` + +
+

+ +

+ +via JSON Parameter file + +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "value": "<>oiwmin001" + } + } +} +``` + +
+