Skip to content

Commit

Permalink
Adds AI services model deployments to provisioning display (#4243)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
wbreza authored Aug 23, 2024
1 parent b7fe33e commit a17935e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 115 deletions.
106 changes: 42 additions & 64 deletions cli/azd/pkg/azapi/azure_resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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)
}
36 changes: 0 additions & 36 deletions cli/azd/pkg/azapi/azure_resource_types_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion cli/azd/pkg/infra/azure_resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
20 changes: 10 additions & 10 deletions cli/azd/pkg/project/framework_service_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a17935e

Please sign in to comment.