Skip to content

Commit afeccfd

Browse files
config role for function (#216)
## Purpose <!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? --> * ... ## Does this introduce a breaking change? <!-- Mark one with an "x". --> ``` [ ] Yes [ ] No ``` fix #221 fix #220 ## Pull Request Type What kind of change does this Pull Request introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [ ] Bugfix [ ] Feature [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [ ] Documentation content changes [ ] Other... Please describe: ``` ## How to Test * Get the code ``` git clone [repo-address] cd [repo-name] git checkout [branch-name] npm install ``` * Test the code <!-- Add steps to run the tests suite and/or manually test --> ``` ``` ## What to Check Verify that the following are valid * ... ## Other Information <!-- Add any other helpful information that may be needed here. --> --------- Co-authored-by: Luis Quintanilla <[email protected]>
1 parent fb1ca32 commit afeccfd

File tree

7 files changed

+29
-25
lines changed

7 files changed

+29
-25
lines changed

app/frontend/Services/ApiClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ public async Task<UploadDocumentsResponse> UploadDocumentsAsync(
3535

3636
foreach (var file in files)
3737
{
38+
// max allow size: 10mb
39+
var max_size = maxAllowedSize * 1024 * 1024;
3840
#pragma warning disable CA2000 // Dispose objects before losing scope
39-
var fileContent = new StreamContent(file.OpenReadStream());
41+
var fileContent = new StreamContent(file.OpenReadStream(max_size));
4042
#pragma warning restore CA2000 // Dispose objects before losing scope
4143
fileContent.Headers.ContentType = new MediaTypeHeaderValue(file.ContentType);
4244

app/functions/EmbedFunctions/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ uri is not null
4242
GetUriFromEnvironment("AZURE_STORAGE_BLOB_ENDPOINT"),
4343
credential);
4444

45-
return blobServiceClient.GetBlobContainerClient("corpus");
45+
var containerClient = blobServiceClient.GetBlobContainerClient("corpus");
46+
47+
containerClient.CreateIfNotExists();
48+
49+
return containerClient;
4650
});
4751

4852
services.AddSingleton<EmbedServiceFactory>();

app/prepdocs/PrepareDocs/Program.Clients.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private static Task<AzureSearchEmbedService> GetAzureSearchEmbedService(AppOptio
2727
var searchIndexClient = await GetSearchIndexClientAsync(o);
2828
var searchClient = await GetSearchClientAsync(o);
2929
var documentClient = await GetFormRecognizerClientAsync(o);
30-
var blobContainerClient = await GetBlobContainerClientAsync(o);
30+
var blobContainerClient = await GetCorpusBlobContainerClientAsync(o);
3131
var openAIClient = await GetAzureOpenAIClientAsync(o);
3232
var embeddingModelName = o.EmbeddingModelName ?? throw new ArgumentNullException(nameof(o.EmbeddingModelName));
3333
var searchIndexName = o.SearchIndexName ?? throw new ArgumentNullException(nameof(o.SearchIndexName));

infra/core/host/container-app-upsert.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ param external bool = true
6464
param serviceBinds array = []
6565

6666
@description('The target port for the container')
67-
param targetPort int = 8080
67+
param targetPort int = 80
6868

6969
resource existingApp 'Microsoft.App/containerApps@2023-04-01-preview' existing = if (exists) {
7070
name: name

infra/core/host/container-app.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ param serviceBinds array = []
6868
param serviceType string = ''
6969

7070
@description('The target port for the container')
71-
param targetPort int = 8080
71+
param targetPort int = 80
7272

7373
resource userIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = if (!empty(identityName)) {
7474
name: identityName

infra/main.bicep

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ param webIdentityName string = ''
140140
@description('Name of the web app image')
141141
param webImageName string = ''
142142

143-
@description('Use Application Insights for monitoring and performance tracing')
144-
param useApplicationInsights bool = false
145-
146143
var abbrs = loadJsonContent('./abbreviations.json')
147144
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
148145

@@ -302,7 +299,7 @@ module function './app/function.bicep' = {
302299
AZURE_SEARCH_SERVICE_ENDPOINT: searchService.outputs.endpoint
303300
AZURE_SEARCH_INDEX: searchIndexName
304301
AZURE_STORAGE_BLOB_ENDPOINT: storage.outputs.primaryEndpoints.blob
305-
AZURE_OPENAI_EMBEDDING_DEPLOYMENT: embeddingModelName
302+
AZURE_OPENAI_EMBEDDING_DEPLOYMENT: embeddingDeploymentName
306303
AZURE_OPENAI_ENDPOINT: openAi.outputs.endpoint
307304
}
308305
}
@@ -316,7 +313,7 @@ module monitoring 'core/monitor/monitoring.bicep' = {
316313
location: location
317314
tags: updatedTags
318315
includeDashboard: false
319-
includeApplicationInsights: useApplicationInsights
316+
includeApplicationInsights: true
320317
logAnalyticsName: !empty(logAnalyticsName) ? logAnalyticsName : '${abbrs.operationalInsightsWorkspaces}${resourceToken}'
321318
applicationInsightsName: !empty(applicationInsightsName) ? applicationInsightsName : '${abbrs.insightsComponents}${resourceToken}'
322319
applicationInsightsDashboardName: !empty(applicationInsightsDashboardName) ? applicationInsightsDashboardName : '${abbrs.portalDashboards}${resourceToken}'
@@ -495,69 +492,69 @@ module openAiRoleFunction 'core/security/role.bicep' = {
495492
scope: openAiResourceGroup
496493
name: 'openai-role-function'
497494
params: {
498-
principalId: principalId
495+
principalId: function.outputs.SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID
499496
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
500-
principalType: principalType
497+
principalType: 'ServicePrincipal'
501498
}
502499
}
503500

504501
module formRecognizerRoleFunction 'core/security/role.bicep' = {
505502
scope: formRecognizerResourceGroup
506503
name: 'formrecognizer-role-function'
507504
params: {
508-
principalId: principalId
505+
principalId: function.outputs.SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID
509506
roleDefinitionId: 'a97b65f3-24c7-4388-baec-2e87135dc908'
510-
principalType: principalType
507+
principalType: 'ServicePrincipal'
511508
}
512509
}
513510

514511
module storageRoleFunction 'core/security/role.bicep' = {
515512
scope: storageResourceGroup
516513
name: 'storage-role-function'
517514
params: {
518-
principalId: principalId
515+
principalId: function.outputs.SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID
519516
roleDefinitionId: '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1'
520-
principalType: principalType
517+
principalType: 'ServicePrincipal'
521518
}
522519
}
523520

524521
module storageContribRoleFunction 'core/security/role.bicep' = {
525522
scope: storageResourceGroup
526523
name: 'storage-contribrole-function'
527524
params: {
528-
principalId: principalId
525+
principalId: function.outputs.SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID
529526
roleDefinitionId: 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'
530-
principalType: principalType
527+
principalType: 'ServicePrincipal'
531528
}
532529
}
533530

534531
module searchRoleFunction 'core/security/role.bicep' = {
535532
scope: searchServiceResourceGroup
536533
name: 'search-role-function'
537534
params: {
538-
principalId: principalId
535+
principalId: function.outputs.SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID
539536
roleDefinitionId: '1407120a-92aa-4202-b7e9-c0e197c71c8f'
540-
principalType: principalType
537+
principalType: 'ServicePrincipal'
541538
}
542539
}
543540

544541
module searchContribRoleFunction 'core/security/role.bicep' = {
545542
scope: searchServiceResourceGroup
546543
name: 'search-contrib-role-function'
547544
params: {
548-
principalId: principalId
545+
principalId: function.outputs.SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID
549546
roleDefinitionId: '8ebe5a00-799e-43f5-93ac-243d3dce84a7'
550-
principalType: principalType
547+
principalType: 'ServicePrincipal'
551548
}
552549
}
553550

554551
module searchSvcContribRoleFunction 'core/security/role.bicep' = {
555552
scope: searchServiceResourceGroup
556553
name: 'search-svccontrib-role-function'
557554
params: {
558-
principalId: principalId
555+
principalId: function.outputs.SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID
559556
roleDefinitionId: '7ca78c08-252a-4471-8644-bb5ff32d4ba0'
560-
principalType: principalType
557+
principalType: 'ServicePrincipal'
561558
}
562559
}
563560

@@ -634,3 +631,4 @@ output AZURE_STORAGE_RESOURCE_GROUP string = storageResourceGroup.name
634631
output AZURE_TENANT_ID string = tenant().tenantId
635632
output SERVICE_WEB_IDENTITY_NAME string = web.outputs.SERVICE_WEB_IDENTITY_NAME
636633
output SERVICE_WEB_NAME string = web.outputs.SERVICE_WEB_NAME
634+
output SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID string = function.outputs.SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID

infra/main.parameters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"value": "${SERVICE_WEB_IDENTITY_NAME}"
7676
},
7777
"useApplicationInsights": {
78-
"value": "${AZURE_USE_APPLICATION_INSIGHTS=false}"
78+
"value": "${AZURE_USE_APPLICATION_INSIGHTS=true}"
7979
}
8080
}
8181
}

0 commit comments

Comments
 (0)