forked from microsoft/aspire
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAzureContainerAppEnvironmentResource.cs
More file actions
93 lines (69 loc) · 4.15 KB
/
AzureContainerAppEnvironmentResource.cs
File metadata and controls
93 lines (69 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Aspire.Hosting.ApplicationModel;
namespace Aspire.Hosting.Azure.AppContainers;
/// <summary>
/// Represents an Azure Container App Environment resource.
/// </summary>
/// <param name="name">The name of the Container App Environment.</param>
/// <param name="configureInfrastructure">The callback to configure the Azure infrastructure for this resource.</param>
public class AzureContainerAppEnvironmentResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure) :
AzureProvisioningResource(name, configureInfrastructure), IAzureContainerAppEnvironment
{
/// <summary>
/// Gets the unique identifier of the Container App Environment.
/// </summary>
private BicepOutputReference ContainerAppEnvironmentId => new("AZURE_CONTAINER_APPS_ENVIRONMENT_ID", this);
/// <summary>
/// Gets the default domain associated with the Container App Environment.
/// </summary>
private BicepOutputReference ContainerAppDomain => new("AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN", this);
/// <summary>
/// Gets the URL endpoint of the associated Azure Container Registry.
/// </summary>
private BicepOutputReference ContainerRegistryUrl => new("AZURE_CONTAINER_REGISTRY_ENDPOINT", this);
/// <summary>
/// Gets the managed identity ID associated with the Azure Container Registry.
/// </summary>
private BicepOutputReference ContainerRegistryManagedIdentityId => new("AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID", this);
/// <summary>
/// Gets the unique identifier of the Log Analytics workspace.
/// </summary>
private BicepOutputReference LogAnalyticsWorkspaceId => new("AZURE_LOG_ANALYTICS_WORKSPACE_ID", this);
/// <summary>
/// Gets the principal name of the managed identity.
/// </summary>
private BicepOutputReference PrincipalName => new("MANAGED_IDENTITY_NAME", this);
/// <summary>
/// Gets the principal ID of the managed identity.
/// </summary>
private BicepOutputReference PrincipalId => new("MANAGED_IDENTITY_PRINCIPAL_ID", this);
/// <summary>
/// Gets the name of the Container App Environment.
/// </summary>
private BicepOutputReference ContainerAppEnvironmentName => new("AZURE_CONTAINER_APPS_ENVIRONMENT_NAME", this);
internal Dictionary<string, BicepOutputReference> VolumeNames { get; } = [];
IManifestExpressionProvider IAzureContainerAppEnvironment.ContainerAppEnvironmentId => ContainerAppEnvironmentId;
IManifestExpressionProvider IAzureContainerAppEnvironment.ContainerAppDomain => ContainerAppDomain;
IManifestExpressionProvider IAzureContainerAppEnvironment.ContainerRegistryUrl => ContainerRegistryUrl;
IManifestExpressionProvider IAzureContainerAppEnvironment.ContainerRegistryManagedIdentityId => ContainerRegistryManagedIdentityId;
IManifestExpressionProvider IAzureContainerAppEnvironment.LogAnalyticsWorkspaceId => LogAnalyticsWorkspaceId;
IManifestExpressionProvider IAzureContainerAppEnvironment.PrincipalId => PrincipalId;
IManifestExpressionProvider IAzureContainerAppEnvironment.PrincipalName => PrincipalName;
IManifestExpressionProvider IAzureContainerAppEnvironment.ContainerAppEnvironmentName => ContainerAppEnvironmentName;
IManifestExpressionProvider IAzureContainerAppEnvironment.GetSecretOutputKeyVault(AzureBicepResource resource)
{
throw new NotSupportedException("Automatic Key vault generation is not supported in this environment. Please create a key vault resource directly.");
}
IManifestExpressionProvider IAzureContainerAppEnvironment.GetVolumeStorage(IResource resource, ContainerMountType type, string volumeIndex)
{
// REVIEW: Should we use the same naming algorithm as azd?
var outputName = $"volumes_{resource.Name}_{volumeIndex}";
if (!VolumeNames.TryGetValue(outputName, out var outputReference))
{
outputReference = new BicepOutputReference(outputName, this);
VolumeNames[outputName] = outputReference;
}
return outputReference;
}
}