Skip to content

Commit

Permalink
fix: remove parameter composing logic from `avm/res/operations-manage…
Browse files Browse the repository at this point in the history
…ment/solution` (#3671)

## Description

This PR addresses the issue with some solutions, which don't follow the
naming patterns described in the [template
reference](https://learn.microsoft.com/en-us/azure/templates/microsoft.operationsmanagement/solutions?pivots=deployment-language-bicep).
To address this, the module passes the parameters to the resource
provider without attempting to compose the names. It is the
responsibility of the user to provide parameters expected by the
resource provider. See parameter descriptions for more details.
Please note that this is a breaking change, the parameters of the
existing deployments have to be updated to match the new format.

Related to #3378 (first part of the fix).

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.operations-management.solution](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.operations-management.solution.yml/badge.svg?branch=users%2Fkrbar%2FsolutionModuleUpdate)](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.operations-management.solution.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [x] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [x] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [x] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

## Checklist

- [x] I'm sure there are no other open Pull Requests for the same
update/change
- [x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->
  • Loading branch information
krbar authored Oct 30, 2024
1 parent 116a89f commit 2980889
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 71 deletions.
156 changes: 120 additions & 36 deletions avm/res/operations-management/solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ The following section provides usage examples for the module, which were used to
- [Using only defaults](#example-1-using-only-defaults)
- [Microsoft solution](#example-2-microsoft-solution)
- [Non-Microsoft solution](#example-3-non-microsoft-solution)
- [WAF-aligned](#example-4-waf-aligned)
- [SQLAuditing solution](#example-4-sqlauditing-solution)
- [WAF-aligned](#example-5-waf-aligned)

### Example 1: _Using only defaults_

Expand All @@ -44,7 +45,8 @@ module solution 'br/public:avm/res/operations-management/solution:<version>' = {
params: {
// Required parameters
logAnalyticsWorkspaceName: '<logAnalyticsWorkspaceName>'
name: 'Updates'
name: '<name>'
product: 'OMSGallery/Updates'
// Non-required parameters
location: '<location>'
}
Expand All @@ -68,7 +70,10 @@ module solution 'br/public:avm/res/operations-management/solution:<version>' = {
"value": "<logAnalyticsWorkspaceName>"
},
"name": {
"value": "Updates"
"value": "<name>"
},
"product": {
"value": "OMSGallery/Updates"
},
// Non-required parameters
"location": {
Expand All @@ -90,7 +95,8 @@ using 'br/public:avm/res/operations-management/solution:<version>'
// Required parameters
param logAnalyticsWorkspaceName = '<logAnalyticsWorkspaceName>'
param name = 'Updates'
param name = '<name>'
param product = 'OMSGallery/Updates'
// Non-required parameters
param location = '<location>'
```
Expand All @@ -113,10 +119,10 @@ module solution 'br/public:avm/res/operations-management/solution:<version>' = {
params: {
// Required parameters
logAnalyticsWorkspaceName: '<logAnalyticsWorkspaceName>'
name: 'AzureAutomation'
name: '<name>'
product: 'OMSGallery/AzureAutomation'
// Non-required parameters
location: '<location>'
product: 'OMSGallery'
publisher: 'Microsoft'
}
}
Expand All @@ -139,15 +145,15 @@ module solution 'br/public:avm/res/operations-management/solution:<version>' = {
"value": "<logAnalyticsWorkspaceName>"
},
"name": {
"value": "AzureAutomation"
"value": "<name>"
},
"product": {
"value": "OMSGallery/AzureAutomation"
},
// Non-required parameters
"location": {
"value": "<location>"
},
"product": {
"value": "OMSGallery"
},
"publisher": {
"value": "Microsoft"
}
Expand All @@ -167,10 +173,10 @@ using 'br/public:avm/res/operations-management/solution:<version>'
// Required parameters
param logAnalyticsWorkspaceName = '<logAnalyticsWorkspaceName>'
param name = 'AzureAutomation'
param name = '<name>'
param product = 'OMSGallery/AzureAutomation'
// Non-required parameters
param location = '<location>'
param product = 'OMSGallery'
param publisher = 'Microsoft'
```

Expand All @@ -193,9 +199,9 @@ module solution 'br/public:avm/res/operations-management/solution:<version>' = {
// Required parameters
logAnalyticsWorkspaceName: '<logAnalyticsWorkspaceName>'
name: 'omsnonms001'
product: 'nonmsTestSolutionProduct'
// Non-required parameters
location: '<location>'
product: 'nonmsTestSolutionProduct'
publisher: 'nonmsTestSolutionPublisher'
}
}
Expand All @@ -220,13 +226,13 @@ module solution 'br/public:avm/res/operations-management/solution:<version>' = {
"name": {
"value": "omsnonms001"
},
"product": {
"value": "nonmsTestSolutionProduct"
},
// Non-required parameters
"location": {
"value": "<location>"
},
"product": {
"value": "nonmsTestSolutionProduct"
},
"publisher": {
"value": "nonmsTestSolutionPublisher"
}
Expand All @@ -247,18 +253,18 @@ using 'br/public:avm/res/operations-management/solution:<version>'
// Required parameters
param logAnalyticsWorkspaceName = '<logAnalyticsWorkspaceName>'
param name = 'omsnonms001'
param product = 'nonmsTestSolutionProduct'
// Non-required parameters
param location = '<location>'
param product = 'nonmsTestSolutionProduct'
param publisher = 'nonmsTestSolutionPublisher'
```

</details>
<p>

### Example 4: _WAF-aligned_
### Example 4: _SQLAuditing solution_

This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework.
This instance deploys the module with the SQLAuditing solution. This solution is authored by Microsoft, but uses a non-standard value for the `product` parameter.


<details>
Expand All @@ -271,10 +277,10 @@ module solution 'br/public:avm/res/operations-management/solution:<version>' = {
params: {
// Required parameters
logAnalyticsWorkspaceName: '<logAnalyticsWorkspaceName>'
name: 'AzureAutomation'
name: '<name>'
product: 'SQLAuditing'
// Non-required parameters
location: '<location>'
product: 'OMSGallery'
publisher: 'Microsoft'
}
}
Expand All @@ -297,14 +303,93 @@ module solution 'br/public:avm/res/operations-management/solution:<version>' = {
"value": "<logAnalyticsWorkspaceName>"
},
"name": {
"value": "AzureAutomation"
"value": "<name>"
},
"product": {
"value": "SQLAuditing"
},
// Non-required parameters
"location": {
"value": "<location>"
},
"publisher": {
"value": "Microsoft"
}
}
}
```

</details>
<p>

<details>

<summary>via Bicep parameters file</summary>

```bicep-params
using 'br/public:avm/res/operations-management/solution:<version>'
// Required parameters
param logAnalyticsWorkspaceName = '<logAnalyticsWorkspaceName>'
param name = '<name>'
param product = 'SQLAuditing'
// Non-required parameters
param location = '<location>'
param publisher = 'Microsoft'
```

</details>
<p>

### Example 5: _WAF-aligned_

This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework.


<details>

<summary>via Bicep module</summary>

```bicep
module solution 'br/public:avm/res/operations-management/solution:<version>' = {
name: 'solutionDeployment'
params: {
// Required parameters
logAnalyticsWorkspaceName: '<logAnalyticsWorkspaceName>'
name: '<name>'
product: 'OMSGallery/AzureAutomation'
// Non-required parameters
location: '<location>'
publisher: 'Microsoft'
}
}
```

</details>
<p>

<details>

<summary>via JSON parameters file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"logAnalyticsWorkspaceName": {
"value": "<logAnalyticsWorkspaceName>"
},
"name": {
"value": "<name>"
},
"product": {
"value": "OMSGallery"
"value": "OMSGallery/AzureAutomation"
},
// Non-required parameters
"location": {
"value": "<location>"
},
"publisher": {
"value": "Microsoft"
Expand All @@ -325,10 +410,10 @@ using 'br/public:avm/res/operations-management/solution:<version>'
// Required parameters
param logAnalyticsWorkspaceName = '<logAnalyticsWorkspaceName>'
param name = 'AzureAutomation'
param name = '<name>'
param product = 'OMSGallery/AzureAutomation'
// Non-required parameters
param location = '<location>'
param product = 'OMSGallery'
param publisher = 'Microsoft'
```

Expand All @@ -342,15 +427,15 @@ param publisher = 'Microsoft'
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`logAnalyticsWorkspaceName`](#parameter-loganalyticsworkspacename) | string | Name of the Log Analytics workspace where the solution will be deployed/enabled. |
| [`name`](#parameter-name) | string | Name of the solution. For Microsoft published gallery solution the target solution resource name will be composed as `{name}({logAnalyticsWorkspaceName})`. |
| [`name`](#parameter-name) | string | Name of the solution.<p>For solutions authored by Microsoft, the name must be in the pattern: `SolutionType(WorkspaceName)`, for example: `AntiMalware(contoso-Logs)`.<p>For solutions authored by third parties, the name should be in the pattern: `SolutionType[WorkspaceName]`, for example `MySolution[contoso-Logs]`.<p>The solution type is case-sensitive. |
| [`product`](#parameter-product) | string | The product name of the deployed solution.<p>For Microsoft published gallery solution it should be `OMSGallery/{solutionType}`, for example `OMSGallery/AntiMalware`.<p>For a third party solution, it can be anything.<p>This is case sensitive. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
| [`location`](#parameter-location) | string | Location for all resources. |
| [`product`](#parameter-product) | string | The product of the deployed solution. For Microsoft published gallery solution it should be `OMSGallery` and the target solution resource product will be composed as `OMSGallery/{name}`. For third party solution, it can be anything. This is case sensitive. |
| [`publisher`](#parameter-publisher) | string | The publisher name of the deployed solution. For Microsoft published gallery solution, it is `Microsoft`. |

### Parameter: `logAnalyticsWorkspaceName`
Expand All @@ -362,7 +447,14 @@ Name of the Log Analytics workspace where the solution will be deployed/enabled.

### Parameter: `name`

Name of the solution. For Microsoft published gallery solution the target solution resource name will be composed as `{name}({logAnalyticsWorkspaceName})`.
Name of the solution.<p>For solutions authored by Microsoft, the name must be in the pattern: `SolutionType(WorkspaceName)`, for example: `AntiMalware(contoso-Logs)`.<p>For solutions authored by third parties, the name should be in the pattern: `SolutionType[WorkspaceName]`, for example `MySolution[contoso-Logs]`.<p>The solution type is case-sensitive.

- Required: Yes
- Type: string

### Parameter: `product`

The product name of the deployed solution.<p>For Microsoft published gallery solution it should be `OMSGallery/{solutionType}`, for example `OMSGallery/AntiMalware`.<p>For a third party solution, it can be anything.<p>This is case sensitive.

- Required: Yes
- Type: string
Expand All @@ -383,14 +475,6 @@ Location for all resources.
- Type: string
- Default: `[resourceGroup().location]`

### Parameter: `product`

The product of the deployed solution. For Microsoft published gallery solution it should be `OMSGallery` and the target solution resource product will be composed as `OMSGallery/{name}`. For third party solution, it can be anything. This is case sensitive.

- Required: No
- Type: string
- Default: `'OMSGallery'`

### Parameter: `publisher`

The publisher name of the deployed solution. For Microsoft published gallery solution, it is `Microsoft`.
Expand Down
22 changes: 12 additions & 10 deletions avm/res/operations-management/solution/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ metadata name = 'Operations Management Solutions'
metadata description = 'This module deploys an Operations Management Solution.'
metadata owner = 'Azure/module-maintainers'

@description('Required. Name of the solution. For Microsoft published gallery solution the target solution resource name will be composed as `{name}({logAnalyticsWorkspaceName})`.')
@description('''Required. Name of the solution.
For solutions authored by Microsoft, the name must be in the pattern: `SolutionType(WorkspaceName)`, for example: `AntiMalware(contoso-Logs)`.
For solutions authored by third parties, the name should be in the pattern: `SolutionType[WorkspaceName]`, for example `MySolution[contoso-Logs]`.
The solution type is case-sensitive.''')
param name string

@description('Required. Name of the Log Analytics workspace where the solution will be deployed/enabled.')
Expand All @@ -11,8 +14,11 @@ param logAnalyticsWorkspaceName string
@description('Optional. Location for all resources.')
param location string = resourceGroup().location

@description('Optional. The product of the deployed solution. For Microsoft published gallery solution it should be `OMSGallery` and the target solution resource product will be composed as `OMSGallery/{name}`. For third party solution, it can be anything. This is case sensitive.')
param product string = 'OMSGallery'
@description('''Required. The product name of the deployed solution.
For Microsoft published gallery solution it should be `OMSGallery/{solutionType}`, for example `OMSGallery/AntiMalware`.
For a third party solution, it can be anything.
This is case sensitive.''')
param product string

@description('Optional. The publisher name of the deployed solution. For Microsoft published gallery solution, it is `Microsoft`.')
param publisher string = 'Microsoft'
Expand Down Expand Up @@ -43,20 +49,16 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2021-06
name: logAnalyticsWorkspaceName
}

var solutionName = publisher == 'Microsoft' ? '${name}(${logAnalyticsWorkspace.name})' : name

var solutionProduct = publisher == 'Microsoft' ? 'OMSGallery/${name}' : product

resource solution 'Microsoft.OperationsManagement/solutions@2015-11-01-preview' = {
name: solutionName
name: name
location: location
properties: {
workspaceResourceId: logAnalyticsWorkspace.id
}
plan: {
name: solutionName
name: name
promotionCode: ''
product: solutionProduct
product: product
publisher: publisher
}
}
Expand Down
Loading

0 comments on commit 2980889

Please sign in to comment.