From a17935e47211ed01780281974c6d63b467de5b14 Mon Sep 17 00:00:00 2001 From: Wallace Breza Date: Fri, 23 Aug 2024 15:31:20 -0700 Subject: [PATCH] Adds AI services model deployments to provisioning display (#4243) - Updates Cognitive Services Account to Azure AI Services - Adds AI Services model deployments to show in provisioning display - Removes check for top level resources on provision display The motivation to top level resource check from provisioning display is based on the fact that we explicitly call out the list of resource types to display. Some child resources like AI model deployments listed above amongst some others are important enough to and warrant display. If we don't want a specific resource type to display we should deprecate it from our explicit list. --- cli/azd/pkg/azapi/azure_resource_types.go | 106 +++++++----------- .../pkg/azapi/azure_resource_types_test.go | 36 ------ cli/azd/pkg/infra/azure_resource_manager.go | 2 +- .../provisioning_progress_display.go | 5 +- .../pkg/project/framework_service_docker.go | 20 ++-- 5 files changed, 54 insertions(+), 115 deletions(-) delete mode 100644 cli/azd/pkg/azapi/azure_resource_types_test.go diff --git a/cli/azd/pkg/azapi/azure_resource_types.go b/cli/azd/pkg/azapi/azure_resource_types.go index 961fc98bcb8..8479d0682bd 100644 --- a/cli/azd/pkg/azapi/azure_resource_types.go +++ b/cli/azd/pkg/azapi/azure_resource_types.go @@ -3,52 +3,50 @@ package azapi -import "strings" - type AzureResourceType string const ( - AzureResourceTypeApim AzureResourceType = "Microsoft.ApiManagement/service" - AzureResourceTypeAppConfig AzureResourceType = "Microsoft.AppConfiguration/configurationStores" - AzureResourceTypeAppInsightComponent AzureResourceType = "Microsoft.Insights/components" - AzureResourceTypeCacheForRedis AzureResourceType = "Microsoft.Cache/redis" - AzureResourceTypeCDNProfile AzureResourceType = "Microsoft.Cdn/profiles" - AzureResourceTypeCosmosDb AzureResourceType = "Microsoft.DocumentDB/databaseAccounts" - AzureResourceTypeContainerApp AzureResourceType = "Microsoft.App/containerApps" - AzureResourceTypeSpringApp AzureResourceType = "Microsoft.AppPlatform/Spring" - AzureResourceTypeContainerAppEnvironment AzureResourceType = "Microsoft.App/managedEnvironments" - AzureResourceTypeDeployment AzureResourceType = "Microsoft.Resources/deployments" - AzureResourceTypeKeyVault AzureResourceType = "Microsoft.KeyVault/vaults" - AzureResourceTypeManagedHSM AzureResourceType = "Microsoft.KeyVault/managedHSMs" - AzureResourceTypeLoadTest AzureResourceType = "Microsoft.LoadTestService/loadTests" - AzureResourceTypeLogAnalyticsWorkspace AzureResourceType = "Microsoft.OperationalInsights/workspaces" - AzureResourceTypePortalDashboard AzureResourceType = "Microsoft.Portal/dashboards" - AzureResourceTypePostgreSqlServer AzureResourceType = "Microsoft.DBforPostgreSQL/flexibleServers" - AzureResourceTypeMySqlServer AzureResourceType = "Microsoft.DBforMySQL/flexibleServers" - AzureResourceTypeResourceGroup AzureResourceType = "Microsoft.Resources/resourceGroups" - AzureResourceTypeStorageAccount AzureResourceType = "Microsoft.Storage/storageAccounts" - AzureResourceTypeStaticWebSite AzureResourceType = "Microsoft.Web/staticSites" - AzureResourceTypeServiceBusNamespace AzureResourceType = "Microsoft.ServiceBus/namespaces" - AzureResourceTypeServicePlan AzureResourceType = "Microsoft.Web/serverfarms" - AzureResourceTypeSqlServer AzureResourceType = "Microsoft.Sql/servers" - AzureResourceTypeVirtualNetwork AzureResourceType = "Microsoft.Network/virtualNetworks" - AzureResourceTypeWebSite AzureResourceType = "Microsoft.Web/sites" - AzureResourceTypeContainerRegistry AzureResourceType = "Microsoft.ContainerRegistry/registries" - AzureResourceTypeManagedCluster AzureResourceType = "Microsoft.ContainerService/managedClusters" - AzureResourceTypeAgentPool AzureResourceType = "Microsoft.ContainerService/managedClusters/agentPools" - AzureResourceTypeCognitiveServiceAccount AzureResourceType = "Microsoft.CognitiveServices/accounts" - AzureResourceTypeSearchService AzureResourceType = "Microsoft.Search/searchServices" - AzureResourceTypeVideoIndexer AzureResourceType = "Microsoft.VideoIndexer/accounts" - AzureResourceTypePrivateEndpoint AzureResourceType = "Microsoft.Network/privateEndpoints" - AzureResourceTypeDevCenter AzureResourceType = "Microsoft.DevCenter/devcenters" - AzureResourceTypeDevCenterProject AzureResourceType = "Microsoft.DevCenter/projects" - AzureResourceTypeMachineLearningWorkspace AzureResourceType = "Microsoft.MachineLearningServices/workspaces" - //nolint:lll - AzureResourceTypeMachineLearningEndpoint AzureResourceType = "Microsoft.MachineLearningServices/workspaces/onlineEndpoints" + AzureResourceTypeApim AzureResourceType = "Microsoft.ApiManagement/service" + AzureResourceTypeAppConfig AzureResourceType = "Microsoft.AppConfiguration/configurationStores" + AzureResourceTypeAppInsightComponent AzureResourceType = "Microsoft.Insights/components" + AzureResourceTypeCacheForRedis AzureResourceType = "Microsoft.Cache/redis" + AzureResourceTypeCDNProfile AzureResourceType = "Microsoft.Cdn/profiles" + AzureResourceTypeCosmosDb AzureResourceType = "Microsoft.DocumentDB/databaseAccounts" + AzureResourceTypeContainerApp AzureResourceType = "Microsoft.App/containerApps" + AzureResourceTypeSpringApp AzureResourceType = "Microsoft.AppPlatform/Spring" + AzureResourceTypeContainerAppEnvironment AzureResourceType = "Microsoft.App/managedEnvironments" + AzureResourceTypeDeployment AzureResourceType = "Microsoft.Resources/deployments" + AzureResourceTypeKeyVault AzureResourceType = "Microsoft.KeyVault/vaults" + AzureResourceTypeManagedHSM AzureResourceType = "Microsoft.KeyVault/managedHSMs" + AzureResourceTypeLoadTest AzureResourceType = "Microsoft.LoadTestService/loadTests" + AzureResourceTypeLogAnalyticsWorkspace AzureResourceType = "Microsoft.OperationalInsights/workspaces" + AzureResourceTypePortalDashboard AzureResourceType = "Microsoft.Portal/dashboards" + AzureResourceTypePostgreSqlServer AzureResourceType = "Microsoft.DBforPostgreSQL/flexibleServers" + AzureResourceTypeMySqlServer AzureResourceType = "Microsoft.DBforMySQL/flexibleServers" + AzureResourceTypeResourceGroup AzureResourceType = "Microsoft.Resources/resourceGroups" + AzureResourceTypeStorageAccount AzureResourceType = "Microsoft.Storage/storageAccounts" + AzureResourceTypeStaticWebSite AzureResourceType = "Microsoft.Web/staticSites" + AzureResourceTypeServiceBusNamespace AzureResourceType = "Microsoft.ServiceBus/namespaces" + AzureResourceTypeServicePlan AzureResourceType = "Microsoft.Web/serverfarms" + AzureResourceTypeSqlServer AzureResourceType = "Microsoft.Sql/servers" + AzureResourceTypeVirtualNetwork AzureResourceType = "Microsoft.Network/virtualNetworks" + AzureResourceTypeWebSite AzureResourceType = "Microsoft.Web/sites" + AzureResourceTypeContainerRegistry AzureResourceType = "Microsoft.ContainerRegistry/registries" + AzureResourceTypeManagedCluster AzureResourceType = "Microsoft.ContainerService/managedClusters" + AzureResourceTypeAgentPool AzureResourceType = "Microsoft.ContainerService/managedClusters/agentPools" + AzureResourceTypeCognitiveServiceAccount AzureResourceType = "Microsoft.CognitiveServices/accounts" + AzureResourceTypeSearchService AzureResourceType = "Microsoft.Search/searchServices" + AzureResourceTypeVideoIndexer AzureResourceType = "Microsoft.VideoIndexer/accounts" + AzureResourceTypePrivateEndpoint AzureResourceType = "Microsoft.Network/privateEndpoints" + AzureResourceTypeDevCenter AzureResourceType = "Microsoft.DevCenter/devcenters" + AzureResourceTypeDevCenterProject AzureResourceType = "Microsoft.DevCenter/projects" + AzureResourceTypeMachineLearningWorkspace AzureResourceType = "Microsoft.MachineLearningServices/workspaces" AzureResourceTypeMachineLearningConnection AzureResourceType = "Microsoft.MachineLearningServices/workspaces/connections" -) -const resourceLevelSeparator = "/" + //nolint:lll + AzureResourceTypeMachineLearningEndpoint AzureResourceType = "Microsoft.MachineLearningServices/workspaces/onlineEndpoints" + AzureResourceTypeCognitiveServiceAccountDeployment AzureResourceType = "Microsoft.CognitiveServices/accounts/deployments" +) // GetResourceTypeDisplayName retrieves the display name for the given resource type. // If the display name was not found for the given resource type, an empty string is returned instead. @@ -108,7 +106,9 @@ func GetResourceTypeDisplayName(resourceType AzureResourceType) string { case AzureResourceTypeAgentPool: return "AKS Agent Pool" case AzureResourceTypeCognitiveServiceAccount: - return "Cognitive Service" + return "Azure AI Services" + case AzureResourceTypeCognitiveServiceAccountDeployment: + return "Azure AI Services Model Deployment" case AzureResourceTypeSearchService: return "Search service" case AzureResourceTypeVideoIndexer: @@ -131,25 +131,3 @@ func GetResourceTypeDisplayName(resourceType AzureResourceType) string { return "" } - -// IsTopLevelResourceType returns true if the resource type is a top-level resource type, otherwise false. -// A top-level resource type is of the format of: {ResourceProvider}/{TopLevelResourceType}, i.e. -// Microsoft.DocumentDB/databaseAccounts -func IsTopLevelResourceType(resourceType AzureResourceType) bool { - // a deployment is not top level, but grouping level - if resourceType == AzureResourceTypeDeployment { - return false - } - - resType := string(resourceType) - firstIndex := strings.Index(resType, resourceLevelSeparator) - - if firstIndex == -1 || - firstIndex == 0 || - firstIndex == len(resType)-1 { - return false - } - - // Should not contain second separator - return !strings.Contains(resType[firstIndex+1:], resourceLevelSeparator) -} diff --git a/cli/azd/pkg/azapi/azure_resource_types_test.go b/cli/azd/pkg/azapi/azure_resource_types_test.go deleted file mode 100644 index 504b2ea36b9..00000000000 --- a/cli/azd/pkg/azapi/azure_resource_types_test.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package azapi - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestIsTopLevelResourceType(t *testing.T) { - var tests = []struct { - resourceType string - result bool - }{ - {"", false}, - {"/", false}, - {"/foo", false}, - {"foo", false}, - {"foo/", false}, - {"foo/b", true}, - {"foo/bar", true}, - {"foo/bar/baz", false}, - {"foo/bar/", false}, - {"Microsoft.Storage/storageAccounts", true}, - {"Microsoft.DocumentDB/databaseAccounts/collections", false}, - } - - for _, test := range tests { - t.Run(fmt.Sprintf("\"%s\")", test.resourceType), func(t *testing.T) { - assert.Equal(t, test.result, IsTopLevelResourceType(AzureResourceType(test.resourceType))) - }) - } -} diff --git a/cli/azd/pkg/infra/azure_resource_manager.go b/cli/azd/pkg/infra/azure_resource_manager.go index 4327c719b18..438e3cd7b1e 100644 --- a/cli/azd/pkg/infra/azure_resource_manager.go +++ b/cli/azd/pkg/infra/azure_resource_manager.go @@ -308,7 +308,7 @@ func (rm *AzureResourceManager) getCognitiveServiceResourceTypeDisplayName( } else if strings.Contains(resource.Kind, "FormRecognizer") { return "Document Intelligence", nil } else { - return "Cognitive Service", nil + return "Azure AI Services", nil } } diff --git a/cli/azd/pkg/infra/provisioning/provisioning_progress_display.go b/cli/azd/pkg/infra/provisioning/provisioning_progress_display.go index b720774ce4d..5a0770e01a4 100644 --- a/cli/azd/pkg/infra/provisioning/provisioning_progress_display.go +++ b/cli/azd/pkg/infra/provisioning/provisioning_progress_display.go @@ -96,10 +96,7 @@ func (display *ProvisioningProgressDisplay) ReportProgress( if operations[i].Properties.TargetResource != nil { resourceId := *operations[i].Properties.TargetResource.ResourceName - if !display.displayedResources[resourceId] && - azapi.IsTopLevelResourceType( - azapi.AzureResourceType(*operations[i].Properties.TargetResource.ResourceType)) { - + if !display.displayedResources[resourceId] { switch *operations[i].Properties.ProvisioningState { case string(armresources.ProvisioningStateSucceeded): newlyDeployedResources = append(newlyDeployedResources, operations[i]) diff --git a/cli/azd/pkg/project/framework_service_docker.go b/cli/azd/pkg/project/framework_service_docker.go index fd3cf190c27..4282c0d7894 100644 --- a/cli/azd/pkg/project/framework_service_docker.go +++ b/cli/azd/pkg/project/framework_service_docker.go @@ -34,19 +34,19 @@ import ( ) type DockerProjectOptions struct { - Path string `yaml:"path,omitempty" json:"path,omitempty"` - Context string `yaml:"context,omitempty" json:"context,omitempty"` - Platform string `yaml:"platform,omitempty" json:"platform,omitempty"` - Target string `yaml:"target,omitempty" json:"target,omitempty"` - Registry osutil.ExpandableString `yaml:"registry,omitempty" json:"registry,omitempty"` - Image osutil.ExpandableString `yaml:"image,omitempty" json:"image,omitempty"` - Tag osutil.ExpandableString `yaml:"tag,omitempty" json:"tag,omitempty"` + Path string `yaml:"path,omitempty" json:"path,omitempty"` + Context string `yaml:"context,omitempty" json:"context,omitempty"` + Platform string `yaml:"platform,omitempty" json:"platform,omitempty"` + Target string `yaml:"target,omitempty" json:"target,omitempty"` + Registry osutil.ExpandableString `yaml:"registry,omitempty" json:"registry,omitempty"` + Image osutil.ExpandableString `yaml:"image,omitempty" json:"image,omitempty"` + Tag osutil.ExpandableString `yaml:"tag,omitempty" json:"tag,omitempty"` RemoteBuild bool `yaml:"remoteBuild,omitempty" json:"remoteBuild,omitempty"` - BuildArgs []string `yaml:"buildArgs,omitempty" json:"buildArgs,omitempty"` + BuildArgs []string `yaml:"buildArgs,omitempty" json:"buildArgs,omitempty"` // not supported from azure.yaml directly yet. Adding it for Aspire to use it, initially. // Aspire would pass the secret keys, which are env vars that azd will set just to run docker build. - BuildSecrets []string `yaml:"-" json:"-"` - BuildEnv []string `yaml:"-" json:"-"` + BuildSecrets []string `yaml:"-" json:"-"` + BuildEnv []string `yaml:"-" json:"-"` } type dockerBuildResult struct {