diff --git a/.github/workflows/ms.operationsmanagement.solutions.yml b/.github/workflows/ms.operationsmanagement.solutions.yml index d55292826d..f833cf12a5 100644 --- a/.github/workflows/ms.operationsmanagement.solutions.yml +++ b/.github/workflows/ms.operationsmanagement.solutions.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.OperationsManagement/solutions/.test/min.parameters.json b/modules/Microsoft.OperationsManagement/solutions/.test/min.parameters.json deleted file mode 100644 index 6844bb4688..0000000000 --- a/modules/Microsoft.OperationsManagement/solutions/.test/min.parameters.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "Updates" - }, - "logAnalyticsWorkspaceName": { - "value": "adp-<>-az-law-sol-001" - } - } -} diff --git a/modules/Microsoft.OperationsManagement/solutions/.test/min/dependencies.bicep b/modules/Microsoft.OperationsManagement/solutions/.test/min/dependencies.bicep new file mode 100644 index 0000000000..ef3592fb5f --- /dev/null +++ b/modules/Microsoft.OperationsManagement/solutions/.test/min/dependencies.bicep @@ -0,0 +1,13 @@ +@description('Optional. The location to deploy to.') +param location string = resourceGroup().location + +@description('Required. The name of the Log Analytics Workspace to create.') +param logAnalyticsWorkspaceName string + +resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = { + name: logAnalyticsWorkspaceName + location: location +} + +@description('The name of the created Log Analytics Workspace.') +output logAnalyticsWorkspaceName string = logAnalytics.name diff --git a/modules/Microsoft.OperationsManagement/solutions/.test/min/deploy.test.bicep b/modules/Microsoft.OperationsManagement/solutions/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..aa5bfd239b --- /dev/null +++ b/modules/Microsoft.OperationsManagement/solutions/.test/min/deploy.test.bicep @@ -0,0 +1,46 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.operationsmanagement.solutions-${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 = 'omsmin' + +// =========== // +// 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: { + logAnalyticsWorkspaceName: 'dep-<>-law-${serviceShort}' + } +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: 'Updates' + logAnalyticsWorkspaceName: resourceGroupResources.outputs.logAnalyticsWorkspaceName + } +} diff --git a/modules/Microsoft.OperationsManagement/solutions/.test/ms.parameters.json b/modules/Microsoft.OperationsManagement/solutions/.test/ms.parameters.json deleted file mode 100644 index c7dcb66400..0000000000 --- a/modules/Microsoft.OperationsManagement/solutions/.test/ms.parameters.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "AzureAutomation" - }, - "logAnalyticsWorkspaceName": { - "value": "adp-<>-az-law-sol-001" - }, - "product": { - "value": "OMSGallery" - }, - "publisher": { - "value": "Microsoft" - } - } -} diff --git a/modules/Microsoft.OperationsManagement/solutions/.test/ms/dependencies.bicep b/modules/Microsoft.OperationsManagement/solutions/.test/ms/dependencies.bicep new file mode 100644 index 0000000000..ef3592fb5f --- /dev/null +++ b/modules/Microsoft.OperationsManagement/solutions/.test/ms/dependencies.bicep @@ -0,0 +1,13 @@ +@description('Optional. The location to deploy to.') +param location string = resourceGroup().location + +@description('Required. The name of the Log Analytics Workspace to create.') +param logAnalyticsWorkspaceName string + +resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = { + name: logAnalyticsWorkspaceName + location: location +} + +@description('The name of the created Log Analytics Workspace.') +output logAnalyticsWorkspaceName string = logAnalytics.name diff --git a/modules/Microsoft.OperationsManagement/solutions/.test/ms/deploy.test.bicep b/modules/Microsoft.OperationsManagement/solutions/.test/ms/deploy.test.bicep new file mode 100644 index 0000000000..2afd1ce7dd --- /dev/null +++ b/modules/Microsoft.OperationsManagement/solutions/.test/ms/deploy.test.bicep @@ -0,0 +1,48 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.operationsmanagement.solutions-${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 = 'omsms' + +// =========== // +// 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: { + logAnalyticsWorkspaceName: 'dep-<>-law-${serviceShort}' + } +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: 'AzureAutomation' + logAnalyticsWorkspaceName: resourceGroupResources.outputs.logAnalyticsWorkspaceName + product: 'OMSGallery' + publisher: 'Microsoft' + } +} diff --git a/modules/Microsoft.OperationsManagement/solutions/.test/nonms.parameters.json b/modules/Microsoft.OperationsManagement/solutions/.test/nonms.parameters.json deleted file mode 100644 index a040bf8d2f..0000000000 --- a/modules/Microsoft.OperationsManagement/solutions/.test/nonms.parameters.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "nonmsTestSolution" - }, - "logAnalyticsWorkspaceName": { - "value": "adp-<>-az-law-sol-001" - }, - "product": { - "value": "nonmsTestSolutionProduct" - }, - "publisher": { - "value": "nonmsTestSolutionPublisher" - } - } -} diff --git a/modules/Microsoft.OperationsManagement/solutions/.test/nonms/dependencies.bicep b/modules/Microsoft.OperationsManagement/solutions/.test/nonms/dependencies.bicep new file mode 100644 index 0000000000..ef3592fb5f --- /dev/null +++ b/modules/Microsoft.OperationsManagement/solutions/.test/nonms/dependencies.bicep @@ -0,0 +1,13 @@ +@description('Optional. The location to deploy to.') +param location string = resourceGroup().location + +@description('Required. The name of the Log Analytics Workspace to create.') +param logAnalyticsWorkspaceName string + +resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = { + name: logAnalyticsWorkspaceName + location: location +} + +@description('The name of the created Log Analytics Workspace.') +output logAnalyticsWorkspaceName string = logAnalytics.name diff --git a/modules/Microsoft.OperationsManagement/solutions/.test/nonms/deploy.test.bicep b/modules/Microsoft.OperationsManagement/solutions/.test/nonms/deploy.test.bicep new file mode 100644 index 0000000000..9799d911c6 --- /dev/null +++ b/modules/Microsoft.OperationsManagement/solutions/.test/nonms/deploy.test.bicep @@ -0,0 +1,48 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.operationsmanagement.solutions-${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 = 'omsnonms' + +// =========== // +// 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: { + logAnalyticsWorkspaceName: 'dep-<>-law-${serviceShort}' + } +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + logAnalyticsWorkspaceName: resourceGroupResources.outputs.logAnalyticsWorkspaceName + product: 'nonmsTestSolutionProduct' + publisher: 'nonmsTestSolutionPublisher' + } +} diff --git a/modules/Microsoft.OperationsManagement/solutions/readme.md b/modules/Microsoft.OperationsManagement/solutions/readme.md index 715f3460e6..df409cc351 100644 --- a/modules/Microsoft.OperationsManagement/solutions/readme.md +++ b/modules/Microsoft.OperationsManagement/solutions/readme.md @@ -63,10 +63,10 @@ The following module usage examples are retrieved from the content of the files ```bicep module solutions './Microsoft.OperationsManagement/solutions/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Solutions' + name: '${uniqueString(deployment().name)}-test-omsmin' params: { // Required parameters - logAnalyticsWorkspaceName: 'adp-<>-az-law-sol-001' + logAnalyticsWorkspaceName: '' name: 'Updates' } } @@ -86,7 +86,7 @@ module solutions './Microsoft.OperationsManagement/solutions/deploy.bicep' = { "parameters": { // Required parameters "logAnalyticsWorkspaceName": { - "value": "adp-<>-az-law-sol-001" + "value": "" }, "name": { "value": "Updates" @@ -106,10 +106,10 @@ module solutions './Microsoft.OperationsManagement/solutions/deploy.bicep' = { ```bicep module solutions './Microsoft.OperationsManagement/solutions/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Solutions' + name: '${uniqueString(deployment().name)}-test-omsms' params: { // Required parameters - logAnalyticsWorkspaceName: 'adp-<>-az-law-sol-001' + logAnalyticsWorkspaceName: '' name: 'AzureAutomation' // Non-required parameters product: 'OMSGallery' @@ -132,7 +132,7 @@ module solutions './Microsoft.OperationsManagement/solutions/deploy.bicep' = { "parameters": { // Required parameters "logAnalyticsWorkspaceName": { - "value": "adp-<>-az-law-sol-001" + "value": "" }, "name": { "value": "AzureAutomation" @@ -159,11 +159,11 @@ module solutions './Microsoft.OperationsManagement/solutions/deploy.bicep' = { ```bicep module solutions './Microsoft.OperationsManagement/solutions/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Solutions' + name: '${uniqueString(deployment().name)}-test-omsnonms' params: { // Required parameters - logAnalyticsWorkspaceName: 'adp-<>-az-law-sol-001' - name: 'nonmsTestSolution' + logAnalyticsWorkspaceName: '' + name: '<>omsnonms001' // Non-required parameters product: 'nonmsTestSolutionProduct' publisher: 'nonmsTestSolutionPublisher' @@ -185,10 +185,10 @@ module solutions './Microsoft.OperationsManagement/solutions/deploy.bicep' = { "parameters": { // Required parameters "logAnalyticsWorkspaceName": { - "value": "adp-<>-az-law-sol-001" + "value": "" }, "name": { - "value": "nonmsTestSolution" + "value": "<>omsnonms001" }, // Non-required parameters "product": {