Skip to content

Commit

Permalink
Updated cmk for cognitive
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr committed Oct 19, 2023
1 parent c6128ab commit 89135eb
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions modules/cognitive-services/account/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,18 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2022-09-01' = if (ena
}
}

resource cMKKeyVault 'Microsoft.KeyVault/vaults@2023-02-01' existing = if (!empty(cMKKeyVaultResourceId)) {
name: last(split(cMKKeyVaultResourceId, '/'))!
scope: resourceGroup(split(cMKKeyVaultResourceId, '/')[2], split(cMKKeyVaultResourceId, '/')[4])
}
resource cMKKeyVault 'Microsoft.KeyVault/vaults@2021-10-01' existing = if (!empty(cMKKeyVaultResourceId)) {
name: last(split((!empty(cMKKeyVaultResourceId) ? cMKKeyVaultResourceId : 'dummyVault'), '/'))!
scope: resourceGroup(split((!empty(cMKKeyVaultResourceId) ? cMKKeyVaultResourceId : '//'), '/')[2], split((!empty(cMKKeyVaultResourceId) ? cMKKeyVaultResourceId : '////'), '/')[4])

resource cMKKeyVaultKey 'Microsoft.KeyVault/vaults/keys@2023-02-01' existing = if (!empty(cMKKeyVaultResourceId) && !empty(cMKKeyName)) {
name: '${last(split(cMKKeyVaultResourceId, '/'))}/${cMKKeyName}'!
scope: resourceGroup(split(cMKKeyVaultResourceId, '/')[2], split(cMKKeyVaultResourceId, '/')[4])
resource cMKKey 'keys@2023-02-01' existing = if (!empty(cMKKeyName)) {
name: !empty(cMKKeyName) ? cMKKeyName : 'dummyKey'
}
}

resource cMKUserAssignedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = if (!empty(cMKUserAssignedIdentityResourceId)) {
name: last(split(cMKUserAssignedIdentityResourceId, '/'))!
scope: resourceGroup(split(cMKUserAssignedIdentityResourceId, '/')[2], split(cMKUserAssignedIdentityResourceId, '/')[4])
name: last(split((!empty(cMKKeyVaultResourceId) ? cMKKeyVaultResourceId : 'dummyMsi'), '/'))!
scope: resourceGroup(split((!empty(cMKKeyVaultResourceId) ? cMKKeyVaultResourceId : '//'), '/')[2], split((!empty(cMKKeyVaultResourceId) ? cMKKeyVaultResourceId : '////'), '/')[4])
}

resource cognitiveServices 'Microsoft.CognitiveServices/accounts@2022-12-01' = {
Expand Down Expand Up @@ -242,7 +241,7 @@ resource cognitiveServices 'Microsoft.CognitiveServices/accounts@2022-12-01' = {
identityClientId: cMKUserAssignedIdentity.properties.clientId
keyVaultUri: cMKKeyVault.properties.vaultUri
keyName: cMKKeyName
keyVersion: !empty(cMKKeyVersion) ? cMKKeyVersion : last(split(cMKKeyVaultKey.properties.keyUriWithVersion, '/'))
keyVersion: !empty(cMKKeyVersion) ? cMKKeyVersion : last(split(cMKKeyVault::cMKKey.properties.keyUriWithVersion, '/'))
}
} : null
migrationToken: !empty(migrationToken) ? migrationToken : null
Expand Down

0 comments on commit 89135eb

Please sign in to comment.