|
6 | 6 | // https://github.com/karamem0/commistant/blob/main/LICENSE |
7 | 7 | // |
8 | 8 |
|
9 | | -#pragma warning disable IDE0059 |
10 | | - |
11 | 9 | using Aspire.Hosting; |
12 | 10 |
|
13 | 11 | var builder = DistributedApplication.CreateBuilder(args); |
14 | 12 |
|
| 13 | +var azurite = builder |
| 14 | + .AddAzureStorage("azurite") |
| 15 | + .RunAsEmulator(azurite => azurite |
| 16 | + .WithBlobPort(10000) |
| 17 | + .WithQueuePort(10001) |
| 18 | + .WithTablePort(10002) |
| 19 | + ); |
| 20 | + |
15 | 21 | var openAIName = builder.AddParameter("AzureOpenAIName"); |
16 | 22 | var openAIResourceGroup = builder.AddParameter("AzureOpenAIResourceGroup"); |
17 | 23 | var openAI = builder |
18 | 24 | .AddAzureOpenAI("openai") |
19 | 25 | .AsExisting(openAIName, openAIResourceGroup); |
20 | 26 |
|
| 27 | +var storageAccountName = builder.AddParameter("AzureStorageAccountName"); |
| 28 | +var storageAccountResourceGroup = builder.AddParameter("AzureStorageAccountResourceGroup"); |
21 | 29 | var storageAccount = builder |
22 | 30 | .AddAzureStorage("storage") |
23 | | - .RunAsEmulator(azurite => azurite |
24 | | - .WithBlobPort(10000) |
25 | | - .WithQueuePort(10001) |
26 | | - .WithTablePort(10002) |
27 | | - ); |
| 31 | + .AsExisting(storageAccountName, storageAccountResourceGroup); |
28 | 32 | var storageContainer = storageAccount.AddBlobContainer("container", "azure-bot-states"); |
29 | 33 |
|
30 | | -var functionApp = builder |
| 34 | +var openAIDeploymentName = builder.AddParameter("AzureOpenAIDeploymentName"); |
| 35 | + |
| 36 | +var botFrameworkMicrosoftAppId = builder.AddParameter("BotFrameworkMicrosoftAppId"); |
| 37 | +var botFrameworkMicrosoftAppPassword = builder.AddParameter("BotFrameworkMicrosoftAppPassword", secret: true); |
| 38 | +var botFrameworkMicrosoftAppTenantId = builder.AddParameter("BotFrameworkMicrosoftAppTenantId"); |
| 39 | + |
| 40 | +var microsoftIdentityClientId = builder.AddParameter("MicrosoftIdentityClientId"); |
| 41 | +var microsoftIdentityClientSecret = builder.AddParameter("MicrosoftIdentityClientSecret"); |
| 42 | +var microsoftIdentityTenantId = builder.AddParameter("MicrosoftIdentityTenantId"); |
| 43 | + |
| 44 | +_ = builder |
31 | 45 | .AddAzureFunctionsProject<Projects.Karamem0_Commistant_Function>("function-app") |
32 | | - .WithReference(storageContainer) |
33 | 46 | .WaitFor(storageContainer) |
34 | | - .WithHostStorage(storageAccount); |
| 47 | + .WaitFor(azurite) |
| 48 | + .WithHostStorage(azurite) |
| 49 | + .WithEnvironment("AzureStorageBlobs:Endpoint", storageAccount.Resource.BlobEndpoint) |
| 50 | + .WithEnvironment("AzureStorageBlobs:ContainerName", storageContainer.Resource.Name) |
| 51 | + .WithEnvironment("BotFramework:MicrosoftAppId", botFrameworkMicrosoftAppId) |
| 52 | + .WithEnvironment("BotFramework:MicrosoftAppPassword", botFrameworkMicrosoftAppPassword) |
| 53 | + .WithEnvironment("BotFramework:MicrosoftAppTenantId", botFrameworkMicrosoftAppTenantId) |
| 54 | + .WithEnvironment("MicrosoftIdentity:ClientId", microsoftIdentityClientId) |
| 55 | + .WithEnvironment("MicrosoftIdentity:ClientSecret", microsoftIdentityClientSecret) |
| 56 | + .WithEnvironment("MicrosoftIdentity:TenantId", microsoftIdentityTenantId); |
35 | 57 |
|
36 | | -var webApp = builder |
| 58 | +_ = builder |
37 | 59 | .AddProject<Projects.Karamem0_Commistant_Web>("web-app") |
38 | | - .WithReference(openAI) |
39 | 60 | .WaitFor(openAI) |
40 | | - .WithReference(storageContainer) |
41 | | - .WaitFor(storageContainer); |
| 61 | + .WaitFor(storageContainer) |
| 62 | + .WithEnvironment("AzureOpenAI:Endpoint", $"https://{openAIName}.openai.azure.com/") |
| 63 | + .WithEnvironment("AzureOpenAI:DeploymentName", openAIDeploymentName) |
| 64 | + .WithEnvironment("AzureStorageBlobs:Endpoint", storageAccount.Resource.BlobEndpoint) |
| 65 | + .WithEnvironment("AzureStorageBlobs:ContainerName", storageContainer.Resource.BlobContainerName) |
| 66 | + .WithEnvironment("BotFramework:MicrosoftAppId", botFrameworkMicrosoftAppId) |
| 67 | + .WithEnvironment("BotFramework:MicrosoftAppPassword", botFrameworkMicrosoftAppPassword) |
| 68 | + .WithEnvironment("BotFramework:MicrosoftAppTenantId", botFrameworkMicrosoftAppTenantId); |
42 | 69 |
|
43 | 70 | var app = builder.Build(); |
44 | 71 |
|
45 | 72 | await app.RunAsync(); |
46 | | - |
47 | | -#pragma warning restore IDE0059 |
|
0 commit comments