Skip to content

Commit 100701a

Browse files
committed
cli script add
1 parent 5474bda commit 100701a

File tree

3 files changed

+742
-16
lines changed

3 files changed

+742
-16
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// ========== Managed Identity ========== //
2+
targetScope = 'resourceGroup'
3+
4+
@minLength(3)
5+
@maxLength(15)
6+
@description('Solution Name')
7+
param solutionName string
8+
9+
@description('Solution Location')
10+
param solutionLocation string
11+
12+
@description('Name')
13+
param miName string = '${ solutionName }-managed-identity'
14+
15+
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
16+
name: miName
17+
location: solutionLocation
18+
tags: {
19+
app: solutionName
20+
location: solutionLocation
21+
}
22+
}
23+
24+
@description('This is the built-in owner role. See https://docs.microsoft.com/azure/role-based-access-control/built-in-roles#owner')
25+
resource ownerRoleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = {
26+
scope: resourceGroup()
27+
name: '8e3af657-a8ff-443c-a75c-2fe8c4bcb635'
28+
}
29+
30+
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
31+
name: guid(resourceGroup().id, managedIdentity.id, ownerRoleDefinition.id)
32+
properties: {
33+
principalId: managedIdentity.properties.principalId
34+
roleDefinitionId: ownerRoleDefinition.id
35+
principalType: 'ServicePrincipal'
36+
}
37+
}
38+
39+
output managedIdentityOutput object = {
40+
id: managedIdentity.id
41+
objectId: managedIdentity.properties.principalId
42+
resourceId: managedIdentity.id
43+
location: managedIdentity.location
44+
name: miName
45+
}
46+
47+
output managedIdentityId string = managedIdentity.id

infra/main.bicep

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
param location string = 'EastUS2' //Fixed for model availability, change back to resourceGroup().location
33

44
@description('Location for OpenAI resources.')
5-
param azureOpenAILocation string = 'EastUS' //Fixed for model availability
5+
param azureOpenAILocation string = 'japaneast' //Fixed for model availability
66

77

88

99
@description('A prefix to add to the start of all resource names. Note: A "unique" suffix will also be added')
10-
param prefix string = 'macae'
10+
param prefix string = 'macae8'
1111

1212
@description('Tags to apply to all deployed resources')
1313
param tags object = {}
@@ -22,7 +22,7 @@ param resourceSize {
2222
maxReplicas: int
2323
}
2424
} = {
25-
gpt4oCapacity: 50
25+
gpt4oCapacity: 1
2626
containerAppSize: {
2727
cpu: '2.0'
2828
memory: '4.0Gi'
@@ -43,7 +43,6 @@ var frontendDockerImageURL = '${resgistryName}.azurecr.io/macaefrontend:${appVer
4343
var uniqueNameFormat = '${prefix}-{0}-${uniqueString(resourceGroup().id, prefix)}'
4444
var aoaiApiVersion = '2024-08-01-preview'
4545

46-
4746
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
4847
name: format(uniqueNameFormat, 'logs')
4948
location: location
@@ -283,7 +282,7 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
283282
}
284283
]
285284
}
286-
285+
287286
}
288287

289288
}
@@ -341,4 +340,31 @@ resource frontendAppService 'Microsoft.Web/sites@2021-02-01' = {
341340
}
342341
}
343342

344-
output cosmosAssignCli string = 'az cosmosdb sql role assignment create --resource-group "${resourceGroup().name}" --account-name "${cosmos.name}" --role-definition-id "${cosmos::contributorRoleDefinition.id}" --scope "${cosmos.id}" --principal-id "fill-in"'
343+
var cosmosAssignCli = 'az cosmosdb sql role assignment create --resource-group "${resourceGroup().name}" --account-name "${cosmos.name}" --role-definition-id "${cosmos::contributorRoleDefinition.id}" --scope "${cosmos.id}" --principal-id "${containerApp.identity.principalId}"'
344+
345+
module managedIdentityModule 'deploy_managed_identity.bicep' = {
346+
name: 'deploy_managed_identity'
347+
params: {
348+
solutionName: prefix
349+
solutionLocation: location
350+
}
351+
scope: resourceGroup(resourceGroup().name)
352+
}
353+
354+
module deploymentScriptCLI 'br/public:avm/res/resources/deployment-script:0.5.1' = {
355+
name: 'deploymentScriptCLI'
356+
params: {
357+
// Required parameters
358+
kind: 'AzureCLI'
359+
name: 'rdsmin001'
360+
// Non-required parameters
361+
azCliVersion: '2.69.0'
362+
location: location
363+
managedIdentities: {
364+
userAssignedResourceIds: [
365+
managedIdentityModule.outputs.managedIdentityId
366+
]
367+
}
368+
scriptContent: cosmosAssignCli
369+
}
370+
}

0 commit comments

Comments
 (0)