Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graduate aspire.dashboard alpha feature #3925

Merged
merged 4 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions cli/azd/pkg/apphost/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ const DaprPubSubComponentType = "pubsub"
// genTemplates is the collection of templates that are used when generating infrastructure files from a manifest.
var genTemplates *template.Template

var aspireDashboardFeature = alpha.MustFeatureKey("aspire.dashboard")

func IsAspireDashboardEnabled(alphaFeatureManager *alpha.FeatureManager) bool {
return alphaFeatureManager.IsEnabled(aspireDashboardFeature)
}

type AspireDashboard struct {
Link string
}
Expand All @@ -61,9 +55,6 @@ func AspireDashboardUrl(
ctx context.Context,
env *environment.Environment,
alphaFeatureManager *alpha.FeatureManager) *AspireDashboard {
if !IsAspireDashboardEnabled(alphaFeatureManager) {
return nil
}

ContainersManagedEnvHost, exists := env.LookupEnv("AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN")
if !exists {
Expand Down Expand Up @@ -170,7 +161,6 @@ func Containers(manifest *Manifest) map[string]genContainer {

type AppHostOptions struct {
AutoConfigureDataProtection bool
AspireDashboard bool
}

// ContainerAppManifestTemplateForProject returns the container app manifest template for a given project.
Expand Down Expand Up @@ -213,10 +203,10 @@ func BicepTemplate(name string, manifest *Manifest, options AppHostOptions) (*me
return nil, err
}

if options.AspireDashboard {
generator.bicepContext.AspireDashboard = true
generator.bicepContext.RequiresPrincipalId = true
}
// Aspire Dashboard workaround
// By setting this, we will give Contributor role to the user running azd for the Container Apps Environment
// See: https://github.com/Azure/azure-dev/issues/3928
generator.bicepContext.RequiresPrincipalId = true

// use the filesystem coming from the manifest
// the in-memory filesystem from the manifest is guaranteed to be initialized and contains all the bicep files
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/pkg/apphost/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func TestAspireDashboardGeneration(t *testing.T) {
m, err := ManifestFromAppHost(ctx, filepath.Join("testdata", "AspireDocker.AppHost.csproj"), mockCli, "")
require.NoError(t, err)

files, err := BicepTemplate("main", m, AppHostOptions{AspireDashboard: true})
files, err := BicepTemplate("main", m, AppHostOptions{})
require.NoError(t, err)

err = fs.WalkDir(files, ".", func(path string, d fs.DirEntry, err error) error {
Expand Down
1 change: 0 additions & 1 deletion cli/azd/pkg/apphost/generate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ type genBicepTemplateContext struct {
HasLogAnalyticsWorkspace bool
RequiresPrincipalId bool
RequiresStorageVolume bool
AspireDashboard bool
AppInsights map[string]genAppInsight
ServiceBuses map[string]genServiceBus
StorageAccounts map[string]genStorageAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10
tags: tags
}

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-preview' = {
name: 'cae-${resourceToken}'
location: location
properties: {
Expand All @@ -65,6 +65,23 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01'
}
}
tags: tags

resource aspireDashboard 'dotNetComponents' = {
name: 'aspire-dashboard'
properties: {
componentType: 'AspireDashboard'
}
}

}

resource explicitContributorUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(containerAppEnvironment.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c'))
scope: containerAppEnvironment
properties: {
principalId: principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
}
}

resource kv854251f1 'Microsoft.KeyVault/vaults@2023-07-01' = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ param environmentName string
@description('The location used for all deployed resources')
param location string

@description('Id of the user or app to assign application roles')
param principalId string = ''

@metadata({azd: {
type: 'generate'
config: {length:15,noSpecial:true,minLower:10,minNumeric:5}
Expand Down Expand Up @@ -68,6 +71,7 @@ module resources 'resources.bicep' = {
params: {
location: location
tags: tags
principalId: principalId
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"principalId": {
"value": "${AZURE_PRINCIPAL_ID}"
},
"my_sql_abstract_pas_sw_ord": {
"value": "${AZURE_MY_SQL_ABSTRACT_PAS_SW_ORD}"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@description('The location used for all deployed resources')
param location string = resourceGroup().location
@description('Id of the user or app to assign application roles')
param principalId string = ''


@description('Tags that will be applied to all resources')
param tags object = {}
Expand Down Expand Up @@ -57,7 +60,7 @@ resource mysqlabstractProjectAppHostVolumeOneFileShare 'Microsoft.Storage/storag
}
}

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-preview' = {
name: 'cae-${resourceToken}'
location: location
properties: {
Expand All @@ -74,6 +77,23 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01'
}
}
tags: tags

resource aspireDashboard 'dotNetComponents' = {
name: 'aspire-dashboard'
properties: {
componentType: 'AspireDashboard'
}
}

}

resource explicitContributorUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(containerAppEnvironment.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c'))
scope: containerAppEnvironment
properties: {
principalId: principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
}
}

resource mySqlAbstractProjectAppHostVolumeTwoStore 'Microsoft.App/managedEnvironments/storages@2023-05-01' = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-p
componentType: 'AspireDashboard'
}
}

}

resource explicitContributorUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(containerAppEnvironment.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c'))
scope: containerAppEnvironment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ param environmentName string
@description('The location used for all deployed resources')
param location string

@description('Id of the user or app to assign application roles')
param principalId string = ''

@metadata({azd: {
type: 'generate'
config: {length:20,noLower:true,minNumeric:5,minSpecial:5}
Expand All @@ -33,6 +36,7 @@ module resources 'resources.bicep' = {
params: {
location: location
tags: tags
principalId: principalId
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"principalId": {
"value": "${AZURE_PRINCIPAL_ID}"
},
"mysqlabstract_password": {
"value": "${AZURE_MYSQLABSTRACT_PASSWORD}"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@description('The location used for all deployed resources')
param location string = resourceGroup().location
@description('Id of the user or app to assign application roles')
param principalId string = ''


@description('Tags that will be applied to all resources')
param tags object = {}
Expand Down Expand Up @@ -45,7 +48,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10
tags: tags
}

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-preview' = {
name: 'cae-${resourceToken}'
location: location
properties: {
Expand All @@ -62,6 +65,23 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01'
}
}
tags: tags

resource aspireDashboard 'dotNetComponents' = {
name: 'aspire-dashboard'
properties: {
componentType: 'AspireDashboard'
}
}

}

resource explicitContributorUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(containerAppEnvironment.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c'))
scope: containerAppEnvironment
properties: {
principalId: principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
}
}

output MANAGED_IDENTITY_CLIENT_ID string = managedIdentity.properties.clientId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ param environmentName string
@description('The location used for all deployed resources')
param location string

@description('Id of the user or app to assign application roles')
param principalId string = ''


var tags = {
'azd-env-name': environmentName
Expand All @@ -26,6 +29,7 @@ module resources 'resources.bicep' = {
params: {
location: location
tags: tags
principalId: principalId
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"principalId": {
"value": "${AZURE_PRINCIPAL_ID}"
},
"environmentName": {
"value": "${AZURE_ENV_NAME}"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@description('The location used for all deployed resources')
param location string = resourceGroup().location
@description('Id of the user or app to assign application roles')
param principalId string = ''


@description('Tags that will be applied to all resources')
param tags object = {}
Expand Down Expand Up @@ -45,7 +48,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10
tags: tags
}

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-preview' = {
name: 'cae-${resourceToken}'
location: location
properties: {
Expand All @@ -62,6 +65,23 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01'
}
}
tags: tags

resource aspireDashboard 'dotNetComponents' = {
name: 'aspire-dashboard'
properties: {
componentType: 'AspireDashboard'
}
}

}

resource explicitContributorUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(containerAppEnvironment.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c'))
scope: containerAppEnvironment
properties: {
principalId: principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
}
}

resource mydata 'Microsoft.Storage/storageAccounts@2022-05-01' = {
Expand Down
8 changes: 2 additions & 6 deletions cli/azd/pkg/project/dotnet_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ func (ai *DotNetImporter) ProjectInfrastructure(ctx context.Context, svcConfig *
return nil, fmt.Errorf("generating app host manifest: %w", err)
}

files, err := apphost.BicepTemplate("main", manifest, apphost.AppHostOptions{
AspireDashboard: apphost.IsAspireDashboardEnabled(ai.alphaFeatureManager),
})
files, err := apphost.BicepTemplate("main", manifest, apphost.AppHostOptions{})
if err != nil {
return nil, fmt.Errorf("generating bicep from manifest: %w", err)
}
Expand Down Expand Up @@ -294,9 +292,7 @@ func (ai *DotNetImporter) SynthAllInfrastructure(
rootModuleName = p.Infra.Module
}

infraFS, err := apphost.BicepTemplate(rootModuleName, manifest, apphost.AppHostOptions{
AspireDashboard: apphost.IsAspireDashboardEnabled(ai.alphaFeatureManager),
})
infraFS, err := apphost.BicepTemplate(rootModuleName, manifest, apphost.AppHostOptions{})
if err != nil {
return nil, fmt.Errorf("generating infra/ folder: %w", err)
}
Expand Down
2 changes: 0 additions & 2 deletions cli/azd/resources/alpha_features.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@
description: "Enable Helm support for AKS deployments."
- id: aks.kustomize
description: "Enable Kustomize support for AKS deployments."
- id: aspire.dashboard
description: "Automatically publish Aspire Dashboard. May not be supported in all regions."
10 changes: 1 addition & 9 deletions cli/azd/resources/apphost/templates/resources.bicept
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,7 @@ resource {{mergeBicepName $name $volume.Name}}FileShare 'Microsoft.Storage/stora
{{- end }}
{{end -}}
{{if .HasContainerEnvironment}}
{{- if eq false .AspireDashboard}}
resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
{{- end }}
{{- if .AspireDashboard}}
resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-preview' = {
{{- end }}
name: 'cae-${resourceToken}'
location: location
properties: {
Expand All @@ -111,7 +106,6 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-p
}
}
tags: tags
{{- if .AspireDashboard }}

resource aspireDashboard 'dotNetComponents' = {
name: 'aspire-dashboard'
Expand All @@ -120,9 +114,8 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-p
}
}

{{- end }}
}
{{- if .AspireDashboard }}

resource explicitContributorUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(containerAppEnvironment.id, principalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c'))
scope: containerAppEnvironment
Expand All @@ -131,7 +124,6 @@ resource explicitContributorUserRoleAssignment 'Microsoft.Authorization/roleAssi
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
}
}
{{- end }}
{{range $name, $value := .ContainerApps}}
{{- range $volume := $value.Volumes}}
resource {{mergeBicepName $name $volume.Name}}Store 'Microsoft.App/managedEnvironments/storages@2023-05-01' = {
Expand Down
Loading
Loading