|
1 | | -targetScope = 'subscription' |
2 | | - |
3 | | -@minLength(1) |
4 | | -@maxLength(64) |
5 | | -@description('Name which is used to generate a short unique hash for each resource') |
6 | | -param name string |
7 | | - |
8 | | -@minLength(1) |
9 | | -@description('Primary location for all resources') |
10 | | -param location string |
11 | | - |
12 | | -@description('Id of the user or app to assign application roles') |
13 | | -param principalId string = '' |
14 | | - |
15 | | -param acaExists bool = false |
16 | | - |
17 | | -@minLength(1) |
18 | | -@description('Location for the Azure AI resource') |
19 | | -// https://learn.microsoft.com/azure/ai-studio/how-to/deploy-models-serverless-availability#deepseek-models-from-microsoft |
20 | | -@allowed([ |
21 | | - 'eastus' |
22 | | - 'eastus2' |
23 | | - 'northcentralus' |
24 | | - 'southcentralus' |
25 | | - 'westus' |
26 | | - 'westus3' |
27 | | -]) |
28 | | -@metadata({ |
29 | | - azd: { |
30 | | - type: 'location' |
31 | | - } |
32 | | -}) |
33 | | -param aiServicesResourceLocation string |
34 | | -param disableKeyBasedAuth bool = true |
35 | | - |
36 | | -// Parameters for the specific Azure AI deployment: |
37 | | -param aiServicesDeploymentName string = 'DeepSeek-R1' |
38 | | - |
39 | | -var resourceToken = toLower(uniqueString(subscription().id, name, location)) |
40 | | -var tags = { 'azd-env-name': name } |
41 | | - |
42 | | -resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { |
43 | | - name: '${name}-rg' |
44 | | - location: location |
45 | | - tags: tags |
46 | | -} |
47 | | - |
48 | | -var prefix = '${name}-${resourceToken}' |
49 | | - |
50 | | -var aiServicesNameAndSubdomain = '${resourceToken}-aiservices' |
51 | | -module aiServices 'br/public:avm/res/cognitive-services/account:0.7.2' = { |
52 | | - name: 'deepseek' |
53 | | - scope: resourceGroup |
54 | | - params: { |
55 | | - name: aiServicesNameAndSubdomain |
56 | | - location: aiServicesResourceLocation |
57 | | - tags: tags |
58 | | - kind: 'AIServices' |
59 | | - customSubDomainName: aiServicesNameAndSubdomain |
60 | | - sku: 'S0' |
61 | | - publicNetworkAccess: 'Enabled' |
62 | | - deployments: [ |
63 | | - { |
64 | | - name: aiServicesDeploymentName |
65 | | - model: { |
66 | | - format: 'DeepSeek' |
67 | | - name: 'DeepSeek-R1' |
68 | | - version: '1' |
69 | | - } |
70 | | - sku: { |
71 | | - name: 'GlobalStandard' |
72 | | - capacity: 1 |
73 | | - } |
74 | | - } |
75 | | - ] |
76 | | - disableLocalAuth: disableKeyBasedAuth |
77 | | - roleAssignments: [ |
78 | | - { |
79 | | - principalId: principalId |
80 | | - principalType: 'User' |
81 | | - roleDefinitionIdOrName: 'Cognitive Services User' |
82 | | - } |
83 | | - ] |
84 | | - } |
85 | | -} |
86 | | - |
87 | | -module logAnalyticsWorkspace 'core/monitor/loganalytics.bicep' = { |
88 | | - name: 'loganalytics' |
89 | | - scope: resourceGroup |
90 | | - params: { |
91 | | - name: '${prefix}-loganalytics' |
92 | | - location: location |
93 | | - tags: tags |
94 | | - } |
95 | | -} |
96 | | - |
97 | | -// Container apps host (including container registry) |
98 | | -module containerApps 'core/host/container-apps.bicep' = { |
99 | | - name: 'container-apps' |
100 | | - scope: resourceGroup |
101 | | - params: { |
102 | | - name: 'app' |
103 | | - location: location |
104 | | - tags: tags |
105 | | - containerAppsEnvironmentName: '${prefix}-containerapps-env' |
106 | | - containerRegistryName: '${replace(prefix, '-', '')}registry' |
107 | | - logAnalyticsWorkspaceName: logAnalyticsWorkspace.outputs.name |
108 | | - } |
109 | | -} |
110 | | - |
111 | | -// Container app frontend |
112 | | -module aca 'aca.bicep' = { |
113 | | - name: 'aca' |
114 | | - scope: resourceGroup |
115 | | - params: { |
116 | | - name: replace('${take(prefix,19)}-ca', '--', '-') |
117 | | - location: location |
118 | | - tags: tags |
119 | | - identityName: '${prefix}-id-aca' |
120 | | - containerAppsEnvironmentName: containerApps.outputs.environmentName |
121 | | - containerRegistryName: containerApps.outputs.registryName |
122 | | - aiServicesDeploymentName: aiServicesDeploymentName |
123 | | - aiServicesEndpoint: 'https://${aiServices.outputs.name}.services.ai.azure.com/models' |
124 | | - exists: acaExists |
125 | | - } |
126 | | -} |
127 | | - |
128 | | -module aiServicesRoleBackend 'core/security/role.bicep' = { |
129 | | - scope: resourceGroup |
130 | | - name: 'aiservices-role-backend' |
131 | | - params: { |
132 | | - principalId: aca.outputs.identityPrincipalId |
133 | | - roleDefinitionId: 'a97b65f3-24c7-4388-baec-2e87135dc908' |
134 | | - principalType: 'ServicePrincipal' |
135 | | - } |
136 | | -} |
137 | | - |
138 | | -output AZURE_LOCATION string = location |
139 | | -output AZURE_TENANT_ID string = tenant().tenantId |
140 | | - |
141 | | -output AZURE_DEEPSEEK_DEPLOYMENT string = aiServicesDeploymentName |
142 | | -output AZURE_INFERENCE_ENDPOINT string = 'https://${aiServices.outputs.name}.services.ai.azure.com/models' |
143 | | - |
144 | | -output SERVICE_ACA_IDENTITY_PRINCIPAL_ID string = aca.outputs.identityPrincipalId |
145 | | -output SERVICE_ACA_NAME string = aca.outputs.name |
146 | | -output SERVICE_ACA_URI string = aca.outputs.uri |
147 | | -output SERVICE_ACA_IMAGE_NAME string = aca.outputs.imageName |
148 | | - |
149 | | -output AZURE_CONTAINER_ENVIRONMENT_NAME string = containerApps.outputs.environmentName |
150 | | -output AZURE_CONTAINER_REGISTRY_ENDPOINT string = containerApps.outputs.registryLoginServer |
151 | | -output AZURE_CONTAINER_REGISTRY_NAME string = containerApps.outputs.registryName |
| 1 | +targetScope = 'subscription' |
| 2 | + |
| 3 | +@minLength(1) |
| 4 | +@maxLength(64) |
| 5 | +@description('Name which is used to generate a short unique hash for each resource') |
| 6 | +param name string |
| 7 | + |
| 8 | +@minLength(1) |
| 9 | +@description('Primary location for all resources') |
| 10 | +param location string |
| 11 | + |
| 12 | +@description('Id of the user or app to assign application roles') |
| 13 | +param principalId string = '' |
| 14 | + |
| 15 | +param acaExists bool = false |
| 16 | + |
| 17 | +@minLength(1) |
| 18 | +@description('Location for the Azure AI resource') |
| 19 | +// https://learn.microsoft.com/azure/ai-studio/how-to/deploy-models-serverless-availability#deepseek-models-from-microsoft |
| 20 | +@allowed([ |
| 21 | + 'eastus' |
| 22 | + 'eastus2' |
| 23 | + 'northcentralus' |
| 24 | + 'southcentralus' |
| 25 | + 'westus' |
| 26 | + 'westus3' |
| 27 | +]) |
| 28 | +@metadata({ |
| 29 | + azd: { |
| 30 | + type: 'location' |
| 31 | + } |
| 32 | +}) |
| 33 | +param aiServicesResourceLocation string |
| 34 | +param disableKeyBasedAuth bool = true |
| 35 | + |
| 36 | +// Parameters for the specific Azure AI deployment: |
| 37 | +param aiServicesDeploymentName string = 'DeepSeek-R1' |
| 38 | + |
| 39 | +var resourceToken = toLower(uniqueString(subscription().id, name, location)) |
| 40 | +var tags = { 'azd-env-name': name } |
| 41 | + |
| 42 | +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { |
| 43 | + name: '${name}-rg' |
| 44 | + location: location |
| 45 | + tags: tags |
| 46 | +} |
| 47 | + |
| 48 | +var prefix = '${name}-${resourceToken}' |
| 49 | + |
| 50 | +var aiServicesNameAndSubdomain = '${resourceToken}-aiservices' |
| 51 | +module aiServices 'br/public:avm/res/cognitive-services/account:0.7.2' = { |
| 52 | + name: 'deepseek' |
| 53 | + scope: resourceGroup |
| 54 | + params: { |
| 55 | + name: aiServicesNameAndSubdomain |
| 56 | + location: aiServicesResourceLocation |
| 57 | + tags: tags |
| 58 | + kind: 'AIServices' |
| 59 | + customSubDomainName: aiServicesNameAndSubdomain |
| 60 | + sku: 'S0' |
| 61 | + publicNetworkAccess: 'Enabled' |
| 62 | + deployments: [ |
| 63 | + { |
| 64 | + name: aiServicesDeploymentName |
| 65 | + model: { |
| 66 | + format: 'DeepSeek' |
| 67 | + name: 'DeepSeek-R1' |
| 68 | + version: '1' |
| 69 | + } |
| 70 | + sku: { |
| 71 | + name: 'GlobalStandard' |
| 72 | + capacity: 1 |
| 73 | + } |
| 74 | + } |
| 75 | + ] |
| 76 | + disableLocalAuth: disableKeyBasedAuth |
| 77 | + roleAssignments: [ |
| 78 | + { |
| 79 | + principalId: principalId |
| 80 | + principalType: 'User' |
| 81 | + roleDefinitionIdOrName: 'Cognitive Services User' |
| 82 | + } |
| 83 | + ] |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +module logAnalyticsWorkspace 'core/monitor/loganalytics.bicep' = { |
| 88 | + name: 'loganalytics' |
| 89 | + scope: resourceGroup |
| 90 | + params: { |
| 91 | + name: '${prefix}-loganalytics' |
| 92 | + location: location |
| 93 | + tags: tags |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +// Container apps host (including container registry) |
| 98 | +module containerApps 'core/host/container-apps.bicep' = { |
| 99 | + name: 'container-apps' |
| 100 | + scope: resourceGroup |
| 101 | + params: { |
| 102 | + name: 'app' |
| 103 | + location: location |
| 104 | + tags: tags |
| 105 | + containerAppsEnvironmentName: '${prefix}-containerapps-env' |
| 106 | + containerRegistryName: '${replace(prefix, '-', '')}registry' |
| 107 | + logAnalyticsWorkspaceName: logAnalyticsWorkspace.outputs.name |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +// Container app frontend |
| 112 | +module aca 'aca.bicep' = { |
| 113 | + name: 'aca' |
| 114 | + scope: resourceGroup |
| 115 | + params: { |
| 116 | + name: replace('${take(prefix,19)}-ca', '--', '-') |
| 117 | + location: location |
| 118 | + tags: tags |
| 119 | + identityName: '${prefix}-id-aca' |
| 120 | + containerAppsEnvironmentName: containerApps.outputs.environmentName |
| 121 | + containerRegistryName: containerApps.outputs.registryName |
| 122 | + aiServicesDeploymentName: aiServicesDeploymentName |
| 123 | + aiServicesEndpoint: 'https://${aiServices.outputs.name}.services.ai.azure.com/models' |
| 124 | + exists: acaExists |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +module aiServicesRoleBackend 'core/security/role.bicep' = { |
| 129 | + scope: resourceGroup |
| 130 | + name: 'aiservices-role-backend' |
| 131 | + params: { |
| 132 | + principalId: aca.outputs.identityPrincipalId |
| 133 | + roleDefinitionId: 'a97b65f3-24c7-4388-baec-2e87135dc908' |
| 134 | + principalType: 'ServicePrincipal' |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | +output AZURE_LOCATION string = location |
| 139 | +output AZURE_TENANT_ID string = tenant().tenantId |
| 140 | + |
| 141 | +output AZURE_DEEPSEEK_DEPLOYMENT string = aiServicesDeploymentName |
| 142 | +output AZURE_INFERENCE_ENDPOINT string = 'https://${aiServices.outputs.name}.services.ai.azure.com/models' |
| 143 | + |
| 144 | +output SERVICE_ACA_IDENTITY_PRINCIPAL_ID string = aca.outputs.identityPrincipalId |
| 145 | +output SERVICE_ACA_NAME string = aca.outputs.name |
| 146 | +output SERVICE_ACA_URI string = aca.outputs.uri |
| 147 | +output SERVICE_ACA_IMAGE_NAME string = aca.outputs.imageName |
| 148 | + |
| 149 | +output AZURE_CONTAINER_ENVIRONMENT_NAME string = containerApps.outputs.environmentName |
| 150 | +output AZURE_CONTAINER_REGISTRY_ENDPOINT string = containerApps.outputs.registryLoginServer |
| 151 | +output AZURE_CONTAINER_REGISTRY_NAME string = containerApps.outputs.registryName |
0 commit comments