-
Notifications
You must be signed in to change notification settings - Fork 436
[Modules] Updated CognitiveServices/Accounts to new dependency approach #1825
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
Merged
Alexander Sehr (AlexanderSehr)
merged 13 commits into
main
from
users/alsehr/1791_CognitiveServices_Accounts
Oct 5, 2022
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d02e547
[Modules] Updated CognitiveServices/Accounts to new dependency approach
AlexanderSehr d5ae5fd
Update to latest
AlexanderSehr c125915
Merge branch 'main' into users/alsehr/1791_CognitiveServices_Accounts
AlexanderSehr 8a4db3a
Update to latest
AlexanderSehr aa235d1
Update to latest
AlexanderSehr 53bb6dc
Update to latest
AlexanderSehr c6dcf66
Updated folder default to common.
AlexanderSehr 109d193
Merge branch 'main' into users/alsehr/1791_CognitiveServices_Accounts
AlexanderSehr 5c59496
Update to latest
AlexanderSehr 92135d2
Update to latest
AlexanderSehr feecfe5
Update to latest
AlexanderSehr 2cdde86
Resolved conflicts
AlexanderSehr ff25ee9
Apply suggestions from code review
AlexanderSehr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
modules/Microsoft.CognitiveServices/accounts/.test/common/dependencies.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| @description('Optional. The location to deploy resources to.') | ||
| param location string = resourceGroup().location | ||
|
|
||
| @description('Required. The name of the Virtual Network to create.') | ||
| param virtualNetworkName string | ||
|
|
||
| @description('Required. The name of the Managed Identity to create.') | ||
| param managedIdentityName string | ||
|
|
||
| resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-01-01' = { | ||
| name: virtualNetworkName | ||
| location: location | ||
| properties: { | ||
| addressSpace: { | ||
| addressPrefixes: [ | ||
| '10.0.0.0/24' | ||
| ] | ||
| } | ||
| subnets: [ | ||
| { | ||
| name: 'defaultSubnet' | ||
| properties: { | ||
| addressPrefix: '10.0.0.0/24' | ||
| serviceEndpoints: [ | ||
| { | ||
| service: 'Microsoft.CognitiveServices' | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource privateDNSZone 'Microsoft.Network/privateDnsZones@2020-06-01' = { | ||
| name: 'privatelink.cognitiveservices.azure.com' | ||
| location: 'global' | ||
|
|
||
| resource virtualNetworkLinks 'virtualNetworkLinks@2020-06-01' = { | ||
| name: '${virtualNetwork.name}-vnetlink' | ||
| location: 'global' | ||
| properties: { | ||
| virtualNetwork: { | ||
| id: virtualNetwork.id | ||
| } | ||
| registrationEnabled: false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { | ||
| name: managedIdentityName | ||
| location: location | ||
| } | ||
|
|
||
| @description('The resource ID of the created Virtual Network Subnet.') | ||
| output subnetResourceId string = virtualNetwork.properties.subnets[0].id | ||
|
|
||
| @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 | ||
|
|
||
| @description('The resource ID of the created Private DNS zone.') | ||
| output privateDNSZoneResourceId string = privateDNSZone.id |
101 changes: 101 additions & 0 deletions
101
modules/Microsoft.CognitiveServices/accounts/.test/common/deploy.test.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| targetScope = 'subscription' | ||
|
|
||
| // ========== // | ||
| // Parameters // | ||
| // ========== // | ||
| @description('Optional. The name of the resource group to deploy for testing purposes.') | ||
| @maxLength(90) | ||
| param resourceGroupName string = 'ms.cognitiveservices.accounts-${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 = 'csacom' | ||
|
|
||
| // =========== // | ||
| // 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: { | ||
| virtualNetworkName: 'dep-<<namePrefix>>-vnet-${serviceShort}' | ||
| managedIdentityName: 'dep-<<namePrefix>>-msi-${serviceShort}' | ||
| } | ||
| } | ||
|
|
||
| // Diagnostics | ||
| // =========== | ||
| module diagnosticDependencies '../../../../.shared/dependencyConstructs/diagnostic.dependencies.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name, location)}-diagnosticDependencies' | ||
| params: { | ||
| storageAccountName: 'dep<<namePrefix>>diasa${serviceShort}01' | ||
| logAnalyticsWorkspaceName: 'dep-<<namePrefix>>-law-${serviceShort}' | ||
| eventHubNamespaceEventHubName: 'dep-<<namePrefix>>-evh-${serviceShort}' | ||
| eventHubNamespaceName: 'dep-<<namePrefix>>-evhns-${serviceShort}' | ||
| location: location | ||
| } | ||
| } | ||
|
|
||
| // ============== // | ||
| // Test Execution // | ||
| // ============== // | ||
|
|
||
| module testDeployment '../../deploy.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name)}-test-${serviceShort}' | ||
| params: { | ||
| name: '<<namePrefix>>${serviceShort}001' | ||
| kind: 'Face' | ||
| customSubDomainName: '<<namePrefix>>xdomain' | ||
| diagnosticLogsRetentionInDays: 7 | ||
| diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId | ||
| diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId | ||
| diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId | ||
| diagnosticEventHubName: diagnosticDependencies.outputs.eventHubNamespaceEventHubName | ||
| lock: 'CanNotDelete' | ||
| networkAcls: { | ||
| defaultAction: 'deny' | ||
| virtualNetworkRules: [ | ||
| { | ||
| action: 'Allow' | ||
| id: resourceGroupResources.outputs.subnetResourceId | ||
| } | ||
| ] | ||
| } | ||
| roleAssignments: [ | ||
| { | ||
| principalIds: [ | ||
| resourceGroupResources.outputs.managedIdentityPrincipalId | ||
| ] | ||
| roleDefinitionIdOrName: 'Reader' | ||
| } | ||
| ] | ||
| sku: 'S0' | ||
| systemAssignedIdentity: true | ||
| userAssignedIdentities: { | ||
| '${resourceGroupResources.outputs.managedIdentityResourceId}': {} | ||
| } | ||
| privateEndpoints: [ | ||
| { | ||
| privateDnsZoneGroup: { | ||
| privateDNSResourceIds: [ | ||
| resourceGroupResources.outputs.privateDNSZoneResourceId | ||
| ] | ||
| } | ||
| service: 'account' | ||
| subnetResourceId: resourceGroupResources.outputs.subnetResourceId | ||
| } | ||
| ] | ||
| } | ||
| } |
34 changes: 0 additions & 34 deletions
34
modules/Microsoft.CognitiveServices/accounts/.test/encr.parameters.json
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
modules/Microsoft.CognitiveServices/accounts/.test/encr/dependencies.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| @description('Optional. The location to deploy resources to.') | ||
| param location string = resourceGroup().location | ||
|
|
||
| @description('Required. The name of the Virtual Network to create.') | ||
| param virtualNetworkName string | ||
|
|
||
| @description('Required. The name of the Managed Identity to create.') | ||
| param managedIdentityName string | ||
|
|
||
| @description('Required. The name of the Key Vault to create.') | ||
| param keyVaultName string | ||
|
|
||
| resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-01-01' = { | ||
| name: virtualNetworkName | ||
| location: location | ||
| properties: { | ||
| addressSpace: { | ||
| addressPrefixes: [ | ||
| '10.0.0.0/24' | ||
| ] | ||
| } | ||
| subnets: [ | ||
| { | ||
| name: 'defaultSubnet' | ||
| properties: { | ||
| addressPrefix: '10.0.0.0/24' | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { | ||
| name: managedIdentityName | ||
| location: location | ||
| } | ||
|
|
||
| resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = { | ||
| name: keyVaultName | ||
| location: location | ||
| properties: { | ||
| sku: { | ||
| family: 'A' | ||
| name: 'standard' | ||
| } | ||
| tenantId: tenant().tenantId | ||
| enablePurgeProtection: true // Required by batch account | ||
| softDeleteRetentionInDays: 7 | ||
| enabledForTemplateDeployment: true | ||
| enabledForDiskEncryption: true | ||
| enabledForDeployment: true | ||
| enableRbacAuthorization: true | ||
| accessPolicies: [] | ||
| } | ||
|
|
||
| resource key 'keys@2022-07-01' = { | ||
| name: 'keyEncryptionKey' | ||
| properties: { | ||
| kty: 'RSA' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource keyPermissions 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| name: guid('msi-${keyVault::key.id}-${location}-${managedIdentity.id}-Key-Reader-RoleAssignment') | ||
| scope: keyVault::key | ||
| properties: { | ||
| principalId: managedIdentity.properties.principalId | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '12338af0-0e69-4776-bea7-57ae8d297424') // Key Vault Crypto User | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } | ||
|
|
||
| @description('The resource ID of the created Virtual Network Subnet.') | ||
| output subnetResourceId string = virtualNetwork.properties.subnets[0].id | ||
|
|
||
| @description('The resource ID of the created Key Vault.') | ||
| output keyVaultResourceId string = keyVault.id | ||
|
|
||
| @description('The vault URI of the created Key Vault.') | ||
| output keyVaultUri string = keyVault.properties.vaultUri | ||
|
|
||
| @description('The name of the created Key Vault encryption key.') | ||
| output keyVaultKeyName string = keyVault::key.name | ||
|
|
||
| @description('The version of the created Key Vault encryption key.') | ||
| output keyVaultKeyVersion string = last(split(keyVault::key.properties.keyUriWithVersion, '/')) | ||
|
|
||
| @description('The resource ID of the created Managed Identity.') | ||
| output managedIdentityResourceId string = managedIdentity.id | ||
|
|
||
| @description('The client ID of the created Managed Identity.') | ||
| output managedIdentityClientId string = managedIdentity.properties.clientId |
66 changes: 66 additions & 0 deletions
66
modules/Microsoft.CognitiveServices/accounts/.test/encr/deploy.test.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| targetScope = 'subscription' | ||
|
|
||
| // ========== // | ||
| // Parameters // | ||
| // ========== // | ||
| @description('Optional. The name of the resource group to deploy for testing purposes.') | ||
| @maxLength(90) | ||
| param resourceGroupName string = 'ms.cognitiveservices.accounts-${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 = 'csaencr' | ||
|
|
||
| @description('Generated. Used as a basis for unique resource names.') | ||
| param baseTime string = utcNow('u') | ||
|
|
||
| // =========== // | ||
| // 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: { | ||
| virtualNetworkName: 'dep-<<namePrefix>>-vnet-${serviceShort}' | ||
| managedIdentityName: 'dep-<<namePrefix>>-msi-${serviceShort}' | ||
| // Adding base time to make the name unique as purge protection must be enabled (but may not be longer than 24 characters total) | ||
| keyVaultName: 'dep-<<namePrefix>>-kv-${serviceShort}-${substring(uniqueString(baseTime), 0, 3)}' | ||
| } | ||
| } | ||
|
|
||
| // ============== // | ||
| // Test Execution // | ||
| // ============== // | ||
|
|
||
| module testDeployment '../../deploy.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name)}-test-${serviceShort}' | ||
| params: { | ||
| name: '<<namePrefix>>${serviceShort}001' | ||
| kind: 'SpeechServices' | ||
| encryption: { | ||
| keySource: 'Microsoft.KeyVault' | ||
| keyVaultProperties: { | ||
| identityClientId: resourceGroupResources.outputs.managedIdentityClientId | ||
| keyName: resourceGroupResources.outputs.keyVaultKeyName | ||
| keyVaultUri: resourceGroupResources.outputs.keyVaultUri | ||
| keyversion: resourceGroupResources.outputs.keyVaultKeyVersion | ||
| } | ||
| } | ||
| publicNetworkAccess: 'Enabled' | ||
| sku: 'S0' | ||
| userAssignedIdentities: { | ||
| '${resourceGroupResources.outputs.managedIdentityResourceId}': {} | ||
| } | ||
| } | ||
| } | ||
12 changes: 0 additions & 12 deletions
12
modules/Microsoft.CognitiveServices/accounts/.test/min.parameters.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.