Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Modules] Updated Healthbot Module to latest API version and added support for user identities #3343

Merged
merged 3 commits into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var builtInRoleNames = {
'User Access Administrator': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')
}

resource healthBot 'Microsoft.HealthBot/healthBots@2021-06-10' existing = {
resource healthBot 'Microsoft.HealthBot/healthBots@2022-08-08' existing = {
name: last(split(resourceId, '/'))!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-
location: location
}

@description('The resource ID of the created Managed Identity.')
output managedIdentityResourceId string = managedIdentity.id

@description('The principal ID of the created Managed Identity.')
output managedIdentityPrincipalId string = managedIdentity.properties.principalId

4 changes: 4 additions & 0 deletions modules/health-bot/health-bots/.test/common/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@ module testDeployment '../../main.bicep' = {
Environment: 'Non-Prod'
Role: 'DeploymentValidation'
}
sku: 'F0'
userAssignedIdentities: {
'${nestedDependencies.outputs.managedIdentityResourceId}': {}
}
}
}
1 change: 1 addition & 0 deletions modules/health-bot/health-bots/.test/min/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ module testDeployment '../../main.bicep' = {
params: {
enableDefaultTelemetry: enableDefaultTelemetry
name: '${namePrefix}${serviceShort}001'
sku: 'F0'
}
}
60 changes: 55 additions & 5 deletions modules/health-bot/health-bots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ This module deploys an Azure Health Bot.
| :-- | :-- |
| `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `Microsoft.HealthBot/healthBots` | [2020-12-08](https://learn.microsoft.com/en-us/azure/templates/Microsoft.HealthBot/2020-12-08/healthBots) |
| `Microsoft.HealthBot/healthBots` | [2022-08-08](https://learn.microsoft.com/en-us/azure/templates/Microsoft.HealthBot/2022-08-08/healthBots) |

## Parameters

**Required parameters**

| Parameter Name | Type | Description |
| :-- | :-- | :-- |
| `name` | string | Name of the resource. |
| Parameter Name | Type | Allowed Values | Description |
| :-- | :-- | :-- | :-- |
| `name` | string | | Name of the resource. |
| `sku` | string | `[C0, F0, S1]` | The name of the Azure Health Bot SKU. |

**Optional parameters**

Expand All @@ -34,8 +35,8 @@ This module deploys an Azure Health Bot.
| `location` | string | `[resourceGroup().location]` | | Location for all resources. |
| `lock` | string | `''` | `['', CanNotDelete, ReadOnly]` | Specify the type of lock. |
| `roleAssignments` | array | `[]` | | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. |
| `sku` | string | `'F0'` | | The resource model definition representing SKU. |
| `tags` | object | `{object}` | | Tags of the resource. |
| `userAssignedIdentities` | object | `{object}` | | The ID(s) to assign to the resource. |


### Parameter Usage: `tags`
Expand Down Expand Up @@ -138,6 +139,39 @@ roleAssignments: [
</details>
<p>

### Parameter Usage: `userAssignedIdentities`

You can specify multiple user assigned identities to a resource by providing additional resource IDs using the following format:

<details>

<summary>Parameter JSON format</summary>

```json
"userAssignedIdentities": {
"value": {
"/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001": {},
"/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002": {}
}
}
```

</details>

<details>

<summary>Bicep format</summary>

```bicep
userAssignedIdentities: {
'/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001': {}
'/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002': {}
}
```

</details>
<p>

## Outputs

| Output Name | Type | Description |
Expand Down Expand Up @@ -170,6 +204,7 @@ module healthBots './health-bot/health-bots/main.bicep' = {
params: {
// Required parameters
name: '<<namePrefix>>hbhbcom001'
sku: 'F0'
// Non-required parameters
enableDefaultTelemetry: '<enableDefaultTelemetry>'
lock: 'CanNotDelete'
Expand All @@ -186,6 +221,9 @@ module healthBots './health-bot/health-bots/main.bicep' = {
Environment: 'Non-Prod'
Role: 'DeploymentValidation'
}
userAssignedIdentities: {
'<managedIdentityResourceId>': {}
}
}
}
```
Expand All @@ -206,6 +244,9 @@ module healthBots './health-bot/health-bots/main.bicep' = {
"name": {
"value": "<<namePrefix>>hbhbcom001"
},
"sku": {
"value": "F0"
},
// Non-required parameters
"enableDefaultTelemetry": {
"value": "<enableDefaultTelemetry>"
Expand All @@ -229,6 +270,11 @@ module healthBots './health-bot/health-bots/main.bicep' = {
"Environment": "Non-Prod",
"Role": "DeploymentValidation"
}
},
"userAssignedIdentities": {
"value": {
"<managedIdentityResourceId>": {}
}
}
}
}
Expand All @@ -249,6 +295,7 @@ module healthBots './health-bot/health-bots/main.bicep' = {
params: {
// Required parameters
name: '<<namePrefix>>hbhbmin001'
sku: 'F0'
// Non-required parameters
enableDefaultTelemetry: '<enableDefaultTelemetry>'
}
Expand All @@ -271,6 +318,9 @@ module healthBots './health-bot/health-bots/main.bicep' = {
"name": {
"value": "<<namePrefix>>hbhbmin001"
},
"sku": {
"value": "F0"
},
// Non-required parameters
"enableDefaultTelemetry": {
"value": "<enableDefaultTelemetry>"
Expand Down
22 changes: 19 additions & 3 deletions modules/health-bot/health-bots/main.bicep
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
@description('Required. Name of the resource.')
param name string

@description('Optional. The resource model definition representing SKU.')
param sku string = 'F0'
@allowed([
'C0'
'F0'
'S1'
])
@description('Required. The name of the Azure Health Bot SKU.')
param sku string

@description('Optional. The ID(s) to assign to the resource.')
param userAssignedIdentities object = {}

@description('Optional. Location for all resources.')
param location string = resourceGroup().location
Expand All @@ -24,6 +32,13 @@ param tags object = {}
@description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).')
param enableDefaultTelemetry bool = true

var identityType = !empty(userAssignedIdentities) ? 'UserAssigned' : 'None'

var identity = identityType != 'None' ? {
type: identityType
userAssignedIdentities: !empty(userAssignedIdentities) ? userAssignedIdentities : null
} : null

resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name, location)}'
properties: {
Expand All @@ -36,10 +51,11 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (ena
}
}

resource azureHealthBot 'Microsoft.HealthBot/healthBots@2020-12-08' = {
resource azureHealthBot 'Microsoft.HealthBot/healthBots@2022-08-08' = {
name: name
location: location
tags: tags
identity: identity
sku: {
name: sku
}
Expand Down