Skip to content

Commit 19ab3d9

Browse files
committed
Clean up
1 parent 0d6ffb4 commit 19ab3d9

File tree

6 files changed

+56
-26
lines changed

6 files changed

+56
-26
lines changed

cli/azd/internal/scaffold/resource_meta.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ var Resources = []ResourceMeta{
112112
},
113113
RoleAssignments: RoleAssignments{
114114
Write: []RoleAssignment{
115+
{
116+
Name: "AzureAIDeveloper",
117+
RoleDefinitionName: "Azure AI Developer",
118+
RoleDefinitionId: "64702f94-c441-49e6-a78b-ef80e0188fee",
119+
Scope: RoleAssignmentScopeGroup,
120+
},
115121
{
116122
Name: "CognitiveServicesUser",
117123
RoleDefinitionName: "Cognitive Services User",

cli/azd/pkg/project/resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (r ResourceType) AzureResourceType() string {
115115
case ResourceTypeKeyVault:
116116
return "Microsoft.KeyVault/vaults"
117117
case ResourceTypeAiProject:
118-
return "Microsoft.MachineLearningServices/workspaces"
118+
return "Microsoft.CognitiveServices/accounts/projects"
119119
case ResourceTypeAiSearch:
120120
return "Microsoft.Search/searchServices"
121121
}

cli/azd/resources/scaffold/base/modules/ai-search-conn.bicep

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,23 @@ resource aiServices 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' ex
3333
}
3434
}
3535
}
36+
37+
resource projectSearchIndexDataContributorAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
38+
scope: search
39+
name: guid(subscription().id, resourceGroup().id, aiServices::project.id, '8ebe5a00-799e-43f5-93ac-243d3dce84a7')
40+
properties: {
41+
principalId: aiServices::project.identity.principalId
42+
principalType: 'ServicePrincipal'
43+
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '8ebe5a00-799e-43f5-93ac-243d3dce84a7')
44+
}
45+
}
46+
47+
resource projectSearchServiceContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
48+
scope: search
49+
name: guid(subscription().id, resourceGroup().id, aiServices::project.id, '7ca78c08-252a-4471-8644-bb5ff32d4ba0')
50+
properties: {
51+
principalId: aiServices::project.identity.principalId
52+
principalType: 'ServicePrincipal'
53+
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '7ca78c08-252a-4471-8644-bb5ff32d4ba0')
54+
}
55+
}

cli/azd/resources/scaffold/templates/ai-project.bicept

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ param envName string
1212

1313
param deployments deploymentsType
1414

15+
@description('Id of the user or app to assign application roles')
16+
param principalId string
17+
1518
resource aiAccount 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
1619
name: 'ai-account-${resourceToken}'
1720
location: location
@@ -46,7 +49,7 @@ resource aiAccount 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
4649
}
4750
]
4851

49-
resource account_name_project_name 'projects@2025-04-01-preview' = {
52+
resource project 'projects' = {
5053
name: envName
5154
location: location
5255
identity: {
@@ -62,40 +65,30 @@ resource aiAccount 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
6265
}
6366
}
6467

65-
resource projectAiDeveloperRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
66-
scope: resourceGroup()
67-
name: guid(subscription().id, resourceGroup().id, aiAccount::account_name_project_name.id, 'fd1bd22b-8476-40bc-a0bc-3260815545e9')
68-
properties: {
69-
principalId: aiAccount::account_name_project_name.identity.principalId
70-
principalType: 'ServicePrincipal'
71-
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', 'fd1bd22b-8476-40bc-a0bc-3260815545e9')
72-
}
73-
}
74-
75-
resource projectSearchIndexDataContributorAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
68+
resource localUserAiDeveloperRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
7669
scope: resourceGroup()
77-
name: guid(subscription().id, resourceGroup().id, aiAccount::account_name_project_name.id, '8ebe5a00-799e-43f5-93ac-243d3dce84a7')
70+
name: guid(subscription().id, resourceGroup().id, 'localUser', '64702f94-c441-49e6-a78b-ef80e0188fee')
7871
properties: {
79-
principalId: aiAccount::account_name_project_name.identity.principalId
80-
principalType: 'ServicePrincipal'
81-
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '8ebe5a00-799e-43f5-93ac-243d3dce84a7')
72+
principalId: principalId
73+
principalType: 'User'
74+
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '64702f94-c441-49e6-a78b-ef80e0188fee')
8275
}
8376
}
8477

85-
resource projectSearchServiceContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
78+
resource localUserCognitiveServicesUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
8679
scope: resourceGroup()
87-
name: guid(subscription().id, resourceGroup().id, aiAccount::account_name_project_name.id, '7ca78c08-252a-4471-8644-bb5ff32d4ba0')
80+
name: guid(subscription().id, resourceGroup().id, 'localUser', 'a97b65f3-24c7-4388-baec-2e87135dc908')
8881
properties: {
89-
principalId: aiAccount::account_name_project_name.identity.principalId
90-
principalType: 'ServicePrincipal'
91-
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '7ca78c08-252a-4471-8644-bb5ff32d4ba0')
82+
principalId: principalId
83+
principalType: 'User'
84+
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', 'a97b65f3-24c7-4388-baec-2e87135dc908')
9285
}
9386
}
9487

95-
output ENDPOINT string = aiAccount::account_name_project_name.properties.endpoints['AI Foundry API']
96-
output projectId string = aiAccount::account_name_project_name.id
88+
output ENDPOINT string = aiAccount::project.properties.endpoints['AI Foundry API']
89+
output projectId string = aiAccount::project.id
9790
output aiServicesAccountName string = aiAccount.name
98-
output aiServicesProjectName string = aiAccount::account_name_project_name.name
91+
output aiServicesProjectName string = aiAccount::project.name
9992

10093
type deploymentsType = {
10194
@description('Specify the name of cognitive service account deployment.')

cli/azd/resources/scaffold/templates/main.bicept

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ module aiModelsDeploy 'ai-project.bicep' = {
7272
tags: tags
7373
location: aiDeploymentsLocation
7474
envName: environmentName
75+
principalId: principalId
7576
{{- if .AiFoundryProject.Models }}
7677
deployments: [
7778
{{- range .AiFoundryProject.Models }}
7879
{
79-
name: '{{bicepName .Name }}deployment'
80+
name: '{{bicepName .Name }}Deployment'
8081
model: {
8182
name: '{{ .Name }}'
8283
format: '{{ .Format }}'

cli/azd/resources/scaffold/templates/resources.bicept

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,16 @@ resource {{bicepName .Name}}backendRoleAzureAIDeveloperRG 'Microsoft.Authorizati
889889
principalType: 'ServicePrincipal'
890890
}
891891
}
892+
893+
resource {{bicepName .Name}}backendRoleCognitiveServicesUserRG 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
894+
name: guid(subscription().id, resourceGroup().id, {{bicepName .Name}}Identity.name, 'a97b65f3-24c7-4388-baec-2e87135dc908')
895+
scope: resourceGroup()
896+
properties: {
897+
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'a97b65f3-24c7-4388-baec-2e87135dc908')
898+
principalId: {{bicepName .Name}}Identity.outputs.principalId
899+
principalType: 'ServicePrincipal'
900+
}
901+
}
892902
{{- end }}
893903
{{- end}}
894904

0 commit comments

Comments
 (0)