diff --git a/cli/azd/cmd/container.go b/cli/azd/cmd/container.go index 40e2375c3c6..093c57b20ee 100644 --- a/cli/azd/cmd/container.go +++ b/cli/azd/cmd/container.go @@ -637,7 +637,6 @@ func registerCommonDependencies(container *ioc.NestedContainer) { container.MustRegisterSingleton(containerregistry.NewRemoteBuildManager) container.MustRegisterSingleton(keyvault.NewKeyVaultService) container.MustRegisterSingleton(storage.NewFileShareService) - container.MustRegisterSingleton(azapi.NewSpringService) container.MustRegisterScoped(project.NewContainerHelper) container.MustRegisterScoped(func(serviceLocator ioc.ServiceLocator) *lazy.Lazy[*project.ContainerHelper] { diff --git a/cli/azd/docs/feature-stages.md b/cli/azd/docs/feature-stages.md index c93c2f5f115..965c979b7b9 100644 --- a/cli/azd/docs/feature-stages.md +++ b/cli/azd/docs/feature-stages.md @@ -42,5 +42,4 @@ As of `1.21.1`, each Azure Developer CLI feature has been evaluated and assigned | Host | Azure Container Apps | Stable | | Host | Azure Functions | Stable | | Host | Azure Kubernetes Service | Beta | -| Host | Azure Spring Apps | Beta | | Host | Azure AI | Beta | diff --git a/cli/azd/pkg/azapi/azure_resource_types.go b/cli/azd/pkg/azapi/azure_resource_types.go index 61827354535..5a347af5e30 100644 --- a/cli/azd/pkg/azapi/azure_resource_types.go +++ b/cli/azd/pkg/azapi/azure_resource_types.go @@ -17,7 +17,6 @@ const ( AzureResourceTypeEventHubsNamespace AzureResourceType = "Microsoft.EventHub/namespaces" AzureResourceTypeContainerApp AzureResourceType = "Microsoft.App/containerApps" AzureResourceTypeContainerAppJob AzureResourceType = "Microsoft.App/jobs" - AzureResourceTypeSpringApp AzureResourceType = "Microsoft.AppPlatform/Spring" AzureResourceTypeContainerAppEnvironment AzureResourceType = "Microsoft.App/managedEnvironments" AzureResourceTypeDeployment AzureResourceType = "Microsoft.Resources/deployments" AzureResourceTypeKeyVault AzureResourceType = "Microsoft.KeyVault/vaults" @@ -127,8 +126,6 @@ func GetResourceTypeDisplayName(resourceType AzureResourceType) string { return "Search service" case AzureResourceTypeVideoIndexer: return "Video Indexer" - case AzureResourceTypeSpringApp: - return "Azure Spring Apps" case AzureResourceTypePrivateEndpoint: return "Private Endpoint" case AzureResourceTypeDevCenter: diff --git a/cli/azd/pkg/azapi/spring_app.go b/cli/azd/pkg/azapi/spring_app.go deleted file mode 100644 index 7d37e4d5f7a..00000000000 --- a/cli/azd/pkg/azapi/spring_app.go +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package azapi - -import ( - "context" - "errors" - "fmt" - "net/url" - "os" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appplatform/armappplatform/v2" - "github.com/Azure/azure-storage-file-go/azfile" - "github.com/azure/azure-dev/cli/azd/pkg/account" -) - -// SpringService provides artifacts upload/deploy and query to Azure Spring Apps (ASA) -type SpringService interface { - // Get Spring app properties - GetSpringAppProperties( - ctx context.Context, - subscriptionId string, - resourceGroupName string, - instanceName string, - appName string, - ) (*SpringAppProperties, error) - // Deploy jar artifact to ASA app deployment - DeploySpringAppArtifact( - ctx context.Context, - subscriptionId string, - resourceGroup string, - instanceName string, - appName string, - relativePath string, - deploymentName string, - ) (*string, error) - // Upload jar artifact to ASA app Storage File - UploadSpringArtifact( - ctx context.Context, - subscriptionId string, - resourceGroup string, - instanceName string, - appName string, - artifactPath string, - ) (*string, error) - // Get Spring app deployment - GetSpringAppDeployment( - ctx context.Context, - subscriptionId string, - resourceGroupName string, - instanceName string, - appName string, - deploymentName string, - ) (*string, error) -} - -type springService struct { - credentialProvider account.SubscriptionCredentialProvider - armClientOptions *arm.ClientOptions -} - -// Creates a new instance of the NewSpringService -func NewSpringService( - credentialProvider account.SubscriptionCredentialProvider, - armClientOptions *arm.ClientOptions, -) SpringService { - return &springService{ - credentialProvider: credentialProvider, - armClientOptions: armClientOptions, - } -} - -type SpringAppProperties struct { - Url []string -} - -func (ss *springService) GetSpringAppProperties( - ctx context.Context, - subscriptionId, resourceGroup, instanceName, appName string, -) (*SpringAppProperties, error) { - client, err := ss.createSpringAppClient(ctx, subscriptionId) - if err != nil { - return nil, err - } - - springApp, err := client.Get(ctx, resourceGroup, instanceName, appName, nil) - if err != nil { - return nil, fmt.Errorf("failed retrieving spring app properties: %w", err) - } - - var url []string - if springApp.Properties != nil && - springApp.Properties.URL != nil && - *springApp.Properties.Public { - url = []string{*springApp.Properties.URL} - } else { - url = []string{} - } - - return &SpringAppProperties{ - Url: url, - }, nil -} - -func (ss *springService) UploadSpringArtifact( - ctx context.Context, - subscriptionId, resourceGroup, instanceName, appName, artifactPath string, -) (*string, error) { - file, err := os.Open(artifactPath) - - if errors.Is(err, os.ErrNotExist) { - return nil, fmt.Errorf("artifact %s does not exist: %w", artifactPath, err) - } - if err != nil { - return nil, fmt.Errorf("reading artifact file %s: %w", artifactPath, err) - } - defer file.Close() - - springClient, err := ss.createSpringAppClient(ctx, subscriptionId) - if err != nil { - return nil, err - } - storageInfo, err := springClient.GetResourceUploadURL(ctx, resourceGroup, instanceName, appName, nil) - if err != nil { - return nil, fmt.Errorf("failed to get resource upload URL: %w", err) - } - - url, err := url.Parse(*storageInfo.UploadURL) - if err != nil { - return nil, fmt.Errorf("failed to parse storage upload url %s : %w", *storageInfo.UploadURL, err) - } - - // Pass NewAnonymousCredential here, since the URL returned by Azure Spring Apps already contains a SAS token - fileURL := azfile.NewFileURL(*url, azfile.NewPipeline(azfile.NewAnonymousCredential(), azfile.PipelineOptions{})) - err = azfile.UploadFileToAzureFile(ctx, file, fileURL, - azfile.UploadToAzureFileOptions{ - Metadata: azfile.Metadata{ - "createdby": "AZD", - }, - }) - - if err != nil { - return nil, fmt.Errorf("failed to upload artifact %s : %w", artifactPath, err) - } - - return storageInfo.RelativePath, nil -} - -func (ss *springService) DeploySpringAppArtifact( - ctx context.Context, - subscriptionId string, - resourceGroup string, - instanceName string, - appName string, - relativePath string, - deploymentName string, -) (*string, error) { - deploymentClient, err := ss.createSpringAppDeploymentClient(ctx, subscriptionId) - if err != nil { - return nil, err - } - - springClient, err := ss.createSpringAppClient(ctx, subscriptionId) - if err != nil { - return nil, err - } - - _, err = ss.createOrUpdateDeployment(deploymentClient, ctx, resourceGroup, instanceName, appName, - deploymentName, relativePath) - if err != nil { - return nil, err - } - resName, err := ss.activeDeployment(springClient, ctx, resourceGroup, instanceName, appName, deploymentName) - if err != nil { - return nil, err - } - - return resName, nil -} - -func (ss *springService) GetSpringAppDeployment( - ctx context.Context, - subscriptionId string, - resourceGroupName string, - instanceName string, - appName string, - deploymentName string, -) (*string, error) { - client, err := ss.createSpringAppDeploymentClient(ctx, subscriptionId) - if err != nil { - return nil, err - } - - resp, err := client.Get(ctx, resourceGroupName, instanceName, appName, deploymentName, nil) - - if err != nil { - return nil, err - } - - return resp.Name, nil -} - -func (ss *springService) createSpringAppClient( - ctx context.Context, - subscriptionId string, -) (*armappplatform.AppsClient, error) { - credential, err := ss.credentialProvider.CredentialForSubscription(ctx, subscriptionId) - if err != nil { - return nil, err - } - - client, err := armappplatform.NewAppsClient(subscriptionId, credential, ss.armClientOptions) - if err != nil { - return nil, fmt.Errorf("creating SpringApp client: %w", err) - } - - return client, nil -} - -func (ss *springService) createSpringAppDeploymentClient( - ctx context.Context, - subscriptionId string, -) (*armappplatform.DeploymentsClient, error) { - credential, err := ss.credentialProvider.CredentialForSubscription(ctx, subscriptionId) - if err != nil { - return nil, err - } - - client, err := armappplatform.NewDeploymentsClient(subscriptionId, credential, ss.armClientOptions) - if err != nil { - return nil, fmt.Errorf("creating SpringAppDeployment client: %w", err) - } - - return client, nil -} - -func (ss *springService) createOrUpdateDeployment( - deploymentClient *armappplatform.DeploymentsClient, - ctx context.Context, - resourceGroup string, - instanceName string, - appName string, - deploymentName string, - relativePath string, -) (*string, error) { - poller, err := deploymentClient.BeginCreateOrUpdate(ctx, resourceGroup, instanceName, appName, deploymentName, - armappplatform.DeploymentResource{ - Properties: &armappplatform.DeploymentResourceProperties{ - Source: &armappplatform.JarUploadedUserSourceInfo{ - Type: to.Ptr("Jar"), - RelativePath: to.Ptr(relativePath), - }, - }, - }, nil) - if err != nil { - return nil, err - } - - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - return nil, err - } - - return res.Name, nil -} - -func (ss *springService) activeDeployment( - springClient *armappplatform.AppsClient, - ctx context.Context, - resourceGroup string, - instanceName string, - appName string, - deploymentName string, -) (*string, error) { - poller, err := springClient.BeginSetActiveDeployments(ctx, resourceGroup, instanceName, appName, - armappplatform.ActiveDeploymentCollection{ - ActiveDeploymentNames: []*string{ - to.Ptr(deploymentName), - }, - }, nil) - - if err != nil { - return nil, err - } - - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - return nil, err - } - - return res.Name, nil -} diff --git a/cli/azd/pkg/azure/resource_ids.go b/cli/azd/pkg/azure/resource_ids.go index 06f78dda008..de71ae61feb 100644 --- a/cli/azd/pkg/azure/resource_ids.go +++ b/cli/azd/pkg/azure/resource_ids.go @@ -74,15 +74,6 @@ func ContainerAppRID(subscriptionId, resourceGroupName, containerAppName string) return returnValue } -func SpringAppRID(subscriptionId, resourceGroupName, springAppName string) string { - returnValue := fmt.Sprintf( - "%s/providers/Microsoft.AppPlatform/Spring/%s", - ResourceGroupRID(subscriptionId, resourceGroupName), - springAppName, - ) - return returnValue -} - func KubernetesServiceRID(subscriptionId, resourceGroupName, clusterName string) string { return fmt.Sprintf( "%s/providers/Microsoft.ContainerService/managedClusters/%s", diff --git a/cli/azd/pkg/project/service_config.go b/cli/azd/pkg/project/service_config.go index 16c0791f3e1..019d752506e 100644 --- a/cli/azd/pkg/project/service_config.go +++ b/cli/azd/pkg/project/service_config.go @@ -37,8 +37,6 @@ type ServiceConfig struct { Docker DockerProjectOptions `yaml:"docker,omitempty"` // The optional K8S / AKS options K8s AksOptions `yaml:"k8s,omitempty"` - // The optional Azure Spring Apps options - Spring SpringOptions `yaml:"spring,omitempty"` // Infrastructure module path relative to the root infra folder Module string `yaml:"module,omitempty"` // The infrastructure provisioning configuration diff --git a/cli/azd/pkg/project/service_target.go b/cli/azd/pkg/project/service_target.go index 5ce1feae9cd..efee8d5807d 100644 --- a/cli/azd/pkg/project/service_target.go +++ b/cli/azd/pkg/project/service_target.go @@ -30,12 +30,12 @@ const ( // DotNetContainerAppTarget is intentionally omitted because it is only used internally when // containerizing .NET projects and is not a valid service host value in azure.yaml. +// SpringAppTarget is intentionally omitted because support has been removed. var builtInServiceTargetKinds = []ServiceTargetKind{ AppServiceTarget, ContainerAppTarget, AzureFunctionTarget, StaticWebAppTarget, - SpringAppTarget, AksTarget, AiEndpointTarget, } diff --git a/cli/azd/pkg/project/service_target_springapp.go b/cli/azd/pkg/project/service_target_springapp.go index 89497ca3cad..2cfe3759ca9 100644 --- a/cli/azd/pkg/project/service_target_springapp.go +++ b/cli/azd/pkg/project/service_target_springapp.go @@ -6,65 +6,51 @@ package project import ( "context" "errors" - "fmt" - "os" - "path/filepath" - "github.com/azure/azure-dev/cli/azd/internal/mapper" "github.com/azure/azure-dev/cli/azd/pkg/async" - "github.com/azure/azure-dev/cli/azd/pkg/azapi" "github.com/azure/azure-dev/cli/azd/pkg/environment" "github.com/azure/azure-dev/cli/azd/pkg/tools" ) -const ( - defaultDeploymentName = "default" +var errSpringAppDeprecated = errors.New( + "Azure Spring Apps is no longer supported. Recommend using Azure Container Apps." + + " For more information, please refer to https://aka.ms/asaretirement", ) -// The Azure Spring Apps configuration options -type SpringOptions struct { - // The deployment name of ASA app - DeploymentName string `yaml:"deploymentName"` -} - type springAppTarget struct { - env *environment.Environment - envManager environment.Manager - springService azapi.SpringService + env *environment.Environment + envManager environment.Manager } // NewSpringAppTarget creates the spring app service target. -// -// The target resource can be partially filled with only ResourceGroupName, since spring apps -// can be provisioned during deployment. func NewSpringAppTarget( env *environment.Environment, envManager environment.Manager, - springService azapi.SpringService, ) ServiceTarget { return &springAppTarget{ - env: env, - envManager: envManager, - springService: springService, + env: env, + envManager: envManager, } } -func (st *springAppTarget) RequiredExternalTools(ctx context.Context, serviceConfig *ServiceConfig) []tools.ExternalTool { +func (st *springAppTarget) RequiredExternalTools( + ctx context.Context, + serviceConfig *ServiceConfig, +) []tools.ExternalTool { return []tools.ExternalTool{} } func (st *springAppTarget) Initialize(ctx context.Context, serviceConfig *ServiceConfig) error { - return nil + return errSpringAppDeprecated } -// Do nothing for Spring Apps func (st *springAppTarget) Package( ctx context.Context, serviceConfig *ServiceConfig, serviceContext *ServiceContext, progress *async.Progress[ServiceProgress], ) (*ServicePackageResult, error) { - return &ServicePackageResult{}, nil + return nil, errSpringAppDeprecated } func (st *springAppTarget) Publish( @@ -75,10 +61,9 @@ func (st *springAppTarget) Publish( progress *async.Progress[ServiceProgress], publishOptions *PublishOptions, ) (*ServicePublishResult, error) { - return &ServicePublishResult{}, nil + return nil, errSpringAppDeprecated } -// Upload artifact to Storage File and deploy to Spring App func (st *springAppTarget) Deploy( ctx context.Context, serviceConfig *ServiceConfig, @@ -86,171 +71,13 @@ func (st *springAppTarget) Deploy( targetResource *environment.TargetResource, progress *async.Progress[ServiceProgress], ) (*ServiceDeployResult, error) { - if err := st.validateTargetResource(targetResource); err != nil { - return nil, fmt.Errorf("validating target resource: %w", err) - } - - deploymentName := serviceConfig.Spring.DeploymentName - if deploymentName == "" { - deploymentName = defaultDeploymentName - } - - _, err := st.springService.GetSpringAppDeployment( - ctx, - targetResource.SubscriptionId(), - targetResource.ResourceGroupName(), - targetResource.ResourceName(), - serviceConfig.Name, - deploymentName, - ) - - if err != nil { - return nil, fmt.Errorf("get deployment '%s' of Spring App '%s' failed: %w", serviceConfig.Name, deploymentName, err) - } - - // Extract package path from service context artifacts - var packagePath string - if artifact, found := serviceContext.Package.FindFirst(WithKind(ArtifactKindDirectory)); found { - packagePath = artifact.Location - } - if packagePath == "" { - return nil, fmt.Errorf("no package artifact found in service context") - } - - // TODO: Consider support container image and buildpacks deployment in the future - // For now, Azure Spring Apps only support jar deployment - ext := ".jar" - artifactPath := filepath.Join(packagePath, AppServiceJavaPackageName+ext) - - _, err = os.Stat(artifactPath) - if errors.Is(err, os.ErrNotExist) { - return nil, fmt.Errorf("artifact %s does not exist: %w", artifactPath, err) - } - if err != nil { - return nil, fmt.Errorf("reading artifact file %s: %w", artifactPath, err) - } - - progress.SetProgress(NewServiceProgress("Uploading spring artifact")) - - relativePath, err := st.springService.UploadSpringArtifact( - ctx, - targetResource.SubscriptionId(), - targetResource.ResourceGroupName(), - targetResource.ResourceName(), - serviceConfig.Name, - artifactPath, - ) - - if err != nil { - return nil, fmt.Errorf("failed to upload spring artifact: %w", err) - } - - progress.SetProgress(NewServiceProgress("Deploying spring artifact")) - - deployResult, err := st.springService.DeploySpringAppArtifact( - ctx, - targetResource.SubscriptionId(), - targetResource.ResourceGroupName(), - targetResource.ResourceName(), - serviceConfig.Name, - *relativePath, - deploymentName, - ) - if err != nil { - return nil, fmt.Errorf("deploying service %s: %w", serviceConfig.Name, err) - } - - // save the storage relative, otherwise the relative path will be overwritten - // in the deployment from Bicep/Terraform - st.env.SetServiceProperty(serviceConfig.Name, "RELATIVE_PATH", *relativePath) - if err := st.envManager.Save(ctx, st.env); err != nil { - return nil, fmt.Errorf("failed updating environment with relative path, %w", err) - } - - progress.SetProgress(NewServiceProgress("Fetching endpoints for spring app service")) - endpoints, err := st.Endpoints(ctx, serviceConfig, targetResource) - if err != nil { - return nil, err - } - - artifacts := ArtifactCollection{} - - // Add deployment result as artifact - if deployResult != nil { - if err := artifacts.Add(&Artifact{ - Kind: ArtifactKindDeployment, - Location: *deployResult, - LocationKind: LocationKindRemote, - Metadata: map[string]string{ - "deploymentName": deploymentName, - "serviceName": serviceConfig.Name, - "resourceName": targetResource.ResourceName(), - "resourceType": targetResource.ResourceType(), - "subscription": targetResource.SubscriptionId(), - "resourceGroup": targetResource.ResourceGroupName(), - "relativePath": *relativePath, - }, - }); err != nil { - return nil, fmt.Errorf("failed to add deployment artifact: %w", err) - } - } - - // Add endpoints as artifacts - for _, endpoint := range endpoints { - if err := artifacts.Add(&Artifact{ - Kind: ArtifactKindEndpoint, - Location: endpoint, - LocationKind: LocationKindRemote, - }); err != nil { - return nil, fmt.Errorf("failed to add endpoint artifact: %w", err) - } - } - - // Add resource artifact - var resourceArtifact *Artifact - if err := mapper.Convert(targetResource, &resourceArtifact); err == nil { - if err := artifacts.Add(resourceArtifact); err != nil { - return nil, fmt.Errorf("failed to add resource artifact: %w", err) - } - } - - return &ServiceDeployResult{ - Artifacts: artifacts, - }, nil + return nil, errSpringAppDeprecated } -// Gets the exposed endpoints for the Spring Apps Service func (st *springAppTarget) Endpoints( ctx context.Context, serviceConfig *ServiceConfig, targetResource *environment.TargetResource, ) ([]string, error) { - springAppProperties, err := st.springService.GetSpringAppProperties( - ctx, - targetResource.SubscriptionId(), - targetResource.ResourceGroupName(), - targetResource.ResourceName(), - serviceConfig.Name, - ) - if err != nil { - return nil, fmt.Errorf("fetching service properties: %w", err) - } - - return springAppProperties.Url, nil -} - -func (st *springAppTarget) validateTargetResource( - targetResource *environment.TargetResource, -) error { - if targetResource.ResourceGroupName() == "" { - return fmt.Errorf("missing resource group name: %s", targetResource.ResourceGroupName()) - } - - if targetResource.ResourceType() != "" { - if err := checkResourceType(targetResource, azapi.AzureResourceTypeSpringApp); err != nil { - return err - } - } - - return nil + return nil, errSpringAppDeprecated } diff --git a/cli/azd/pkg/project/service_target_springapp_test.go b/cli/azd/pkg/project/service_target_springapp_test.go deleted file mode 100644 index a79060449cc..00000000000 --- a/cli/azd/pkg/project/service_target_springapp_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package project - -import ( - "strings" - "testing" - - "github.com/azure/azure-dev/cli/azd/pkg/azapi" - "github.com/azure/azure-dev/cli/azd/pkg/environment" - "github.com/stretchr/testify/require" -) - -func TestNewSpringAppTargetTypeValidation(t *testing.T) { - t.Parallel() - - tests := map[string]*serviceTargetValidationTest{ - "ValidateTypeSuccess": { - targetResource: environment.NewTargetResource( - "SUB_ID", - "RG_ID", - "res", - string(azapi.AzureResourceTypeSpringApp), - ), - expectError: false, - }, - "ValidateTypeLowerCaseSuccess": { - targetResource: environment.NewTargetResource( - "SUB_ID", - "RG_ID", - "res", - strings.ToLower(string(azapi.AzureResourceTypeSpringApp)), - ), - expectError: false, - }, - "ValidateTypeFail": { - targetResource: environment.NewTargetResource("SUB_ID", "RG_ID", "res", "BadType"), - expectError: true, - }, - } - - for test, data := range tests { - t.Run(test, func(t *testing.T) { - serviceTarget := &springAppTarget{} - - err := serviceTarget.validateTargetResource(data.targetResource) - if data.expectError { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/azure.yaml b/cli/azd/test/functional/testdata/samples/springapp/azure.yaml deleted file mode 100644 index f3c87ea039f..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/azure.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: webapp -metadata: - template: azd-test/webapptest@v1 -services: - helloworld-web: - project: ./ - host: springapp - language: java -infra: - path: infra-bicep - diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/core/host/springapps.bicep b/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/core/host/springapps.bicep deleted file mode 100644 index 2fdae563499..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/core/host/springapps.bicep +++ /dev/null @@ -1,43 +0,0 @@ -param environmentName string -param relativePath string -param location string = resourceGroup().location -var tags = { 'azd-env-name': environmentName } -var resourceToken = toLower(uniqueString(subscription().id, environmentName, location)) - - -resource asaInstance 'Microsoft.AppPlatform/Spring@2022-12-01' = { - name: 'asa-${resourceToken}' - location: location - tags: union(tags, { 'azd-service-name': 'helloworld-web' }) -} - -resource asaApp 'Microsoft.AppPlatform/Spring/apps@2022-12-01' = { - name: 'helloworld-web' - location: location - parent: asaInstance - identity: { - type: 'SystemAssigned' - } - properties: { - public: true - } -} - -resource asaDeployment 'Microsoft.AppPlatform/Spring/apps/deployments@2022-12-01' = { - name: 'default' - parent: asaApp - properties: { - deploymentSettings: { - resourceRequests: { - cpu: '1' - memory: '2Gi' - } - } - source: { - type: 'Jar' - runtimeVersion: 'Java_11' - relativePath: relativePath - } - } -} - diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/main.bicep b/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/main.bicep deleted file mode 100644 index 544fb045c53..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/main.bicep +++ /dev/null @@ -1,33 +0,0 @@ -targetScope = 'subscription' - -@minLength(1) -@maxLength(64) -@description('Name of the the environment which is used to generate a short unique hash used in all resources.') -param environmentName string - -@description('Primary location for all resources') -param location string - -@description('Relative Path of ASA Jar') -param relativePath string - -@description('A time to mark on created resource groups, so they can be cleaned up via an automated process.') -param deleteAfterTime string = dateTimeAdd(utcNow('o'), 'PT1H') - -var tags = { 'azd-env-name': environmentName, DeleteAfter: deleteAfterTime } - -resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = { - name: 'rg-${environmentName}' - location: location - tags: tags -} - -module springapps 'core/host/springapps.bicep' = { - name: 'springapps' - scope: rg - params: { - environmentName: environmentName - location: location - relativePath: relativePath - } -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/main.parameters.json b/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/main.parameters.json deleted file mode 100644 index fb731f6d6b6..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-bicep/main.parameters.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "environmentName": { - "value": "${AZURE_ENV_NAME}" - }, - "location": { - "value": "${AZURE_LOCATION}" - }, - "relativePath": { - "value": "${SERVICE_HELLOWORLD_WEB_RELATIVE_PATH=}" - } - } -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/main.tf b/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/main.tf deleted file mode 100644 index 22d085456b8..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/main.tf +++ /dev/null @@ -1,34 +0,0 @@ -locals { - tags = { azd-env-name : var.environment_name, spring-cloud-azure : true } - sha = base64encode(sha256("${var.environment_name}${var.location}${data.azurerm_client_config.current.subscription_id}")) - resource_token = substr(replace(lower(local.sha), "[^A-Za-z0-9_]", ""), 0, 13) -} -# ------------------------------------------------------------------------------------------------------ -# Deploy resource Group -# ------------------------------------------------------------------------------------------------------ -resource "azurecaf_name" "rg_name" { - name = var.environment_name - resource_type = "azurerm_resource_group" - random_length = 0 - clean_input = true -} - -resource "azurerm_resource_group" "rg" { - name = azurecaf_name.rg_name.result - location = var.location - - tags = local.tags -} - - -# ------------------------------------------------------------------------------------------------------ -# Deploy Azure Container Apps api -# ------------------------------------------------------------------------------------------------------ -module "asa_api" { - name = "asa-${local.resource_token}" - source = "./modules/springapps" - location = var.location - rg_name = azurerm_resource_group.rg.name - - tags = merge(local.tags, { azd-service-name : "sweb" }) -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/main.tfvars.json b/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/main.tfvars.json deleted file mode 100644 index a21fb21bd59..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/main.tfvars.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "location": "${AZURE_LOCATION}", - "environment_name": "${AZURE_ENV_NAME}", - "principal_id": "${AZURE_PRINCIPAL_ID}" -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/modules/springapps/springapps.tf b/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/modules/springapps/springapps.tf deleted file mode 100644 index 742c56dc1be..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/modules/springapps/springapps.tf +++ /dev/null @@ -1,61 +0,0 @@ -terraform { - required_providers { - azurerm = { - version = "~>3.33.0" - source = "hashicorp/azurerm" - } - azurecaf = { - source = "aztfmod/azurecaf" - version = "~>1.2.15" - } - azapi = { - source = "Azure/azapi" - version = "~>1.1.0" - } - } -} - - -data "azurerm_subscription" "current" {} - - -resource "azurerm_spring_cloud_service" "asa_instance" { - name = var.name - resource_group_name = var.rg_name - location = var.location - sku_name = "S0" - - tags = var.tags -} - - -resource "azurerm_spring_cloud_app" "asa_app" { - name = "sweb" - resource_group_name = var.rg_name - service_name = azurerm_spring_cloud_service.asa_instance.name - - is_public = true - - identity { - type = "SystemAssigned" - } -} - - -resource "azurerm_spring_cloud_java_deployment" "deployment" { - name = "default" - spring_cloud_app_id = azurerm_spring_cloud_app.asa_app.id - instance_count = 1 - - quota { - cpu = "1" - memory = "2Gi" - } - - runtime_version = "Java_11" - - environment_variables = { - "Foo" : "Bar" - "Env" : "Staging" - } -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/modules/springapps/springapps_variable.tf b/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/modules/springapps/springapps_variable.tf deleted file mode 100644 index 44f9eb4a8a7..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/modules/springapps/springapps_variable.tf +++ /dev/null @@ -1,26 +0,0 @@ -variable "location" { - description = "The supported Azure location where the resource deployed" - type = string -} - -variable "rg_name" { - description = "The name of the resource group to deploy resources into" - type = string -} - -variable "tags" { - description = "A list of tags used for deployed services." - type = map(string) -} - -variable "identity" { - description = "A list of application identity" - type = list(any) - default = [] -} - -variable "name" { - description = "Name of Container App" - type = string -} - diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/provider.tf b/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/provider.tf deleted file mode 100644 index 73d5fe049d5..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/provider.tf +++ /dev/null @@ -1,37 +0,0 @@ -#Set the terraform required version, and Configure the Azure Provider.Use local storage - -# Configure the Azure Provider -terraform { - required_version = ">= 1.1.7, < 2.0.0" - required_providers { - azurerm = { - version = "~>3.33.0" - source = "hashicorp/azurerm" - } - azurecaf = { - source = "aztfmod/azurecaf" - version = "~>1.2.15" - } - azapi = { - source = "Azure/azapi" - version = "~>1.1.0" - } - } -} - -provider "azurerm" { - skip_provider_registration = "true" - features { - key_vault { - purge_soft_delete_on_destroy = false - } - resource_group { - prevent_deletion_if_contains_resources = false - } - } -} - -# Make client_id, tenant_id, subscription_id and object_id variables -data "azurerm_client_config" "current" {} - -data "azurerm_subscription" "current" {} \ No newline at end of file diff --git a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/variables.tf b/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/variables.tf deleted file mode 100644 index a639ee6bb31..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/infra-terraform/variables.tf +++ /dev/null @@ -1,9 +0,0 @@ -variable "location" { - description = "The supported Azure location where the resource deployed" - type = string -} - -variable "environment_name" { - description = "The name of the azd environment to be deployed" - type = string -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/pom.xml b/cli/azd/test/functional/testdata/samples/springapp/pom.xml deleted file mode 100644 index 9474b81e3d2..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.5.6 - - - com.microsoft.azure - webapp - 0.0.1-SNAPSHOT - webapp - Simple Web App with Spring Boot - - 11 - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.yaml - snakeyaml - 2.4 - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/cli/azd/test/functional/testdata/samples/springapp/src/main/java/com/microsoft/azure/webapp/WebappApplication.java b/cli/azd/test/functional/testdata/samples/springapp/src/main/java/com/microsoft/azure/webapp/WebappApplication.java deleted file mode 100644 index 7bbceee95a3..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/src/main/java/com/microsoft/azure/webapp/WebappApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.microsoft.azure.webapp; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class WebappApplication { - - public static void main(String[] args) { - SpringApplication.run(WebappApplication.class, args); - } - -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/src/main/java/com/microsoft/azure/webapp/web/HelloController.java b/cli/azd/test/functional/testdata/samples/springapp/src/main/java/com/microsoft/azure/webapp/web/HelloController.java deleted file mode 100644 index 94e0f2fddc3..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/src/main/java/com/microsoft/azure/webapp/web/HelloController.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.microsoft.azure.webapp.web; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping - public ResponseEntity hello() { - return ResponseEntity.ok("Hello, `azd`."); - } - -} diff --git a/cli/azd/test/functional/testdata/samples/springapp/src/main/resources/application.properties b/cli/azd/test/functional/testdata/samples/springapp/src/main/resources/application.properties deleted file mode 100644 index 4c00e40debf..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.port=8080 diff --git a/cli/azd/test/functional/testdata/samples/springapp/src/test/java/com/microsoft/azure/webapp/WebappApplicationTests.java b/cli/azd/test/functional/testdata/samples/springapp/src/test/java/com/microsoft/azure/webapp/WebappApplicationTests.java deleted file mode 100644 index 5c7ffa80e51..00000000000 --- a/cli/azd/test/functional/testdata/samples/springapp/src/test/java/com/microsoft/azure/webapp/WebappApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.microsoft.azure.webapp; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class WebappApplicationTests { - - @Test - void contextLoads() { - } - -}