project

package
v0.0.0-...-6ab3b6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: MIT Imports: 82 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AiHubNameEnvVarName is the environment variable name for the Azure AI Hub name
	AiHubNameEnvVarName = "AZUREAI_HUB_NAME"
	// AiProjectNameEnvVarName is the environment variable name for the Azure AI project name
	AiProjectNameEnvVarName = "AZUREAI_PROJECT_NAME"
	/* #nosec G101 - Potential hardcoded credentials - false positive */
	// AiEnvironmentEnvVarName is the environment variable name for the Azure AI environment name
	AiEnvironmentEnvVarName = "AZUREAI_ENVIRONMENT_NAME"
	// AiModelEnvVarName is the environment variable name for the Azure AI model name
	AiModelEnvVarName = "AZUREAI_MODEL_NAME"
	// AiEndpointEnvVarName is the environment variable name for the Azure AI endpoint name
	AiEndpointEnvVarName = "AZUREAI_ENDPOINT_NAME"
	// AiDeploymentEnvVarName is the environment variable name for the Azure AI deployment name
	AiDeploymentEnvVarName = "AZUREAI_DEPLOYMENT_NAME"
	// AiFlowEnvVarName is the environment variable name for the Azure AI flow name
	AiFlowEnvVarName = "AZUREAI_FLOW_NAME"
)
View Source
const (
	DefaultModule = "main"
	DefaultPath   = "infra"
)

defaultOptions for infra settings. These values are applied across provisioning providers.

View Source
const (
	ProjectEventDeploy    ext.Event = "deploy"
	ProjectEventProvision ext.Event = "provision"
)
View Source
const (
	ServiceEventEnvUpdated ext.Event = "environment updated"
	ServiceEventRestore    ext.Event = "restore"
	ServiceEventBuild      ext.Event = "build"
	ServiceEventPackage    ext.Event = "package"
	ServiceEventDeploy     ext.Event = "deploy"
)
View Source
const AppServiceJavaPackageName = "app"

The default, conventional App Service Java package name

View Source
const DefaultBuilderImage = "mcr.microsoft.com/oryx/builder:debian-bullseye-20231107.2"

Default builder image to produce container images from source

View Source
const DefaultStaticWebAppEnvironmentName = "default"

TODO: Enhance for multi-environment support https://github.com/Azure/azure-dev/issues/1152

Variables

View Source
var (
	ProjectEvents []ext.Event = []ext.Event{
		ProjectEventProvision,
		ProjectEventDeploy,
	}
	ErrNoDefaultService = errors.New("no default service selection matches the working directory")
)

Functions

func LoadConfig

func LoadConfig(ctx context.Context, projectFilePath string) (config.Config, error)

func OverriddenEndpoints

func OverriddenEndpoints(ctx context.Context, serviceConfig *ServiceConfig, env *environment.Environment) []string

func Save

func Save(ctx context.Context, projectConfig *ProjectConfig, projectFilePath string) error

Saves the current instance back to the azure.yaml file

func SaveConfig

func SaveConfig(ctx context.Context, config config.Config, projectFilePath string) error

Types

type AiEndpointDeploymentResult

type AiEndpointDeploymentResult struct {
	Environment *armmachinelearning.EnvironmentVersion
	Model       *armmachinelearning.ModelVersion
	Flow        *ai.Flow
	Deployment  *armmachinelearning.OnlineDeployment
}

AiEndpointDeploymentResult is a struct to hold the result of an online endpoint deployment

type AiHelper

type AiHelper interface {
	// RequiredExternalTools returns the required external tools for the AiHelper
	RequiredExternalTools(ctx context.Context) []tools.ExternalTool
	// Initialize initializes the AiHelper
	Initialize(ctx context.Context) error
	// ValidateWorkspace ensures that the workspace exists
	ValidateWorkspace(ctx context.Context, scope *ai.Scope) error
	// CreateEnvironmentVersion creates a new environment version
	CreateEnvironmentVersion(
		ctx context.Context,
		scope *ai.Scope,
		serviceConfig *ServiceConfig,
		config *ai.ComponentConfig,
	) (*armmachinelearning.EnvironmentVersion, error)
	// CreateModelVersion creates a new model version
	CreateModelVersion(
		ctx context.Context,
		scope *ai.Scope,
		serviceConfig *ServiceConfig,
		config *ai.ComponentConfig,
	) (*armmachinelearning.ModelVersion, error)
	// GetEndpoint retrieves an online endpoint
	GetEndpoint(ctx context.Context, scope *ai.Scope, endpointName string) (*armmachinelearning.OnlineEndpoint, error)
	// DeployToEndpoint deploys a new online deployment to an online endpoint
	DeployToEndpoint(
		ctx context.Context,
		scope *ai.Scope,
		serviceConfig *ServiceConfig,
		endpointName string,
		config *ai.EndpointDeploymentConfig,
	) (*armmachinelearning.OnlineDeployment, error)
	// DeletePreviousDeployments deletes all previous deployments of an online endpoint except the one with 100% traffic
	DeletePreviousDeployments(ctx context.Context, scope *ai.Scope, endpointName string) error
	// UpdateTraffic updates the traffic distribution of an online endpoint for the specified deployment
	UpdateTraffic(
		ctx context.Context,
		scope *ai.Scope,
		endpointName string,
		deploymentName string,
	) (*armmachinelearning.OnlineEndpoint, error)
	// CreateFlow creates a new flow
	CreateFlow(
		ctx context.Context,
		scope *ai.Scope,
		serviceConfig *ServiceConfig,
		config *ai.ComponentConfig,
	) (*ai.Flow, error)
}

func NewAiHelper

func NewAiHelper(
	env *environment.Environment,
	clock clock.Clock,
	pythonBridge ai.PythonBridge,
	credentialProvider account.SubscriptionCredentialProvider,
	armClientOptions *arm.ClientOptions,
) AiHelper

NewAiHelper creates a new instance of AiHelper

type AksDeploymentOptions

type AksDeploymentOptions struct {
	Name string `yaml:"name"`
}

The AKS deployment options

type AksIngressOptions

type AksIngressOptions struct {
	Name         string `yaml:"name"`
	RelativePath string `yaml:"relativePath"`
}

The AKS ingress options

type AksOptions

type AksOptions struct {
	// The namespace used for deploying k8s resources. Defaults to the project name
	Namespace string `yaml:"namespace"`
	// The relative folder path from the service that contains the k8s deployment manifests. Defaults to 'manifests'
	DeploymentPath string `yaml:"deploymentPath"`
	// The services ingress configuration options
	Ingress AksIngressOptions `yaml:"ingress"`
	// The services deployment configuration options
	Deployment AksDeploymentOptions `yaml:"deployment"`
	// The services service configuration options
	Service AksServiceOptions `yaml:"service"`
	// The helm configuration options
	Helm *helm.Config `yaml:"helm"`
	// The kustomize configuration options
	Kustomize *kustomize.Config `yaml:"kustomize"`
}

The AKS configuration options

type AksServiceOptions

type AksServiceOptions struct {
	Name string `yaml:"name"`
}

The AKS service configuration options

type CompositeFrameworkService

type CompositeFrameworkService interface {
	FrameworkService
	SetSource(inner FrameworkService)
}

CompositeFrameworkService is a framework service that requires a nested framework service. An example would be a Docker project that uses another framework services such as NPM or Python as a dependency. This supports local inner-loop as well as release restore & package support.

func NewDockerProject

func NewDockerProject(
	env *environment.Environment,
	docker docker.Docker,
	containerHelper *ContainerHelper,
	console input.Console,
	alphaFeatureManager *alpha.FeatureManager,
	commandRunner exec.CommandRunner,
) CompositeFrameworkService

NewDockerProject creates a new instance of a Azd project that leverages docker for building

type ContainerHelper

type ContainerHelper struct {
	// contains filtered or unexported fields
}

func NewContainerHelper

func NewContainerHelper(
	env *environment.Environment,
	envManager environment.Manager,
	clock clock.Clock,
	containerRegistryService azcli.ContainerRegistryService,
	docker docker.Docker,
	cloud *cloud.Cloud,
) *ContainerHelper

func (*ContainerHelper) Credentials

func (ch *ContainerHelper) Credentials(
	ctx context.Context,
	serviceConfig *ServiceConfig,
	targetResource *environment.TargetResource,
) (*azcli.DockerCredentials, error)

func (*ContainerHelper) Deploy

func (ch *ContainerHelper) Deploy(
	ctx context.Context,
	serviceConfig *ServiceConfig,
	packageOutput *ServicePackageResult,
	targetResource *environment.TargetResource,
	writeImageToEnv bool,
) *async.TaskWithProgress[*ServiceDeployResult, ServiceProgress]

Deploy pushes and image to a remote server, and optionally writes the fully qualified remote image name to the environment on success.

func (*ContainerHelper) GeneratedImage

func (ch *ContainerHelper) GeneratedImage(
	ctx context.Context,
	serviceConfig *ServiceConfig,
) (*docker.ContainerImage, error)

GeneratedImage returns the configured image from the service configuration or a default image name generated from the service name and environment name.

func (*ContainerHelper) LocalImageTag

func (ch *ContainerHelper) LocalImageTag(ctx context.Context, serviceConfig *ServiceConfig) (string, error)

LocalImageTag returns the local image tag for the service configuration.

func (*ContainerHelper) Login

func (ch *ContainerHelper) Login(
	ctx context.Context,
	serviceConfig *ServiceConfig,
) (string, error)

Login logs into the container registry specified by AZURE_CONTAINER_REGISTRY_ENDPOINT in the environment. On success, it returns the name of the container registry that was logged into.

func (*ContainerHelper) RegistryName

func (ch *ContainerHelper) RegistryName(ctx context.Context, serviceConfig *ServiceConfig) (string, error)

RegistryName returns the name of the destination container registry to use for the current environment from the following: 1. AZURE_CONTAINER_REGISTRY_ENDPOINT environment variable 2. docker.registry from the service configuration

func (*ContainerHelper) RemoteImageTag

func (ch *ContainerHelper) RemoteImageTag(
	ctx context.Context,
	serviceConfig *ServiceConfig,
	localImageTag string,
) (string, error)

RemoteImageTag returns the remote image tag for the service configuration.

func (*ContainerHelper) RequiredExternalTools

func (ch *ContainerHelper) RequiredExternalTools(context.Context) []tools.ExternalTool

type DockerProjectOptions

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"`
	BuildArgs []string                `yaml:"buildArgs,omitempty" json:"buildArgs,omitempty"`
}

type DotNetContainerAppOptions

type DotNetContainerAppOptions struct {
	Manifest    *apphost.Manifest
	AppHostPath string
	ProjectName string
	// ContainerImage is non-empty when a prebuilt container image is being used.
	ContainerImage string
}

type DotNetImporter

type DotNetImporter struct {
	// contains filtered or unexported fields
}

DotNetImporter is an importer that is able to import projects and infrastructure from a manifest produced by a .NET App.

func NewDotNetImporter

func NewDotNetImporter(
	dotnetCli dotnet.DotNetCli,
	console input.Console,
	lazyEnv *lazy.Lazy[*environment.Environment],
	lazyEnvManager *lazy.Lazy[environment.Manager],
	alphaFeatureManager *alpha.FeatureManager,
) *DotNetImporter

func (*DotNetImporter) CanImport

func (ai *DotNetImporter) CanImport(ctx context.Context, projectPath string) (bool, error)

CanImport returns true when the given project can be imported by this importer. Only some .NET Apps are able to produce the manifest that importer expects.

func (*DotNetImporter) ProjectInfrastructure

func (ai *DotNetImporter) ProjectInfrastructure(ctx context.Context, svcConfig *ServiceConfig) (*Infra, error)

func (*DotNetImporter) ReadManifest

func (ai *DotNetImporter) ReadManifest(ctx context.Context, svcConfig *ServiceConfig) (*apphost.Manifest, error)

ReadManifest reads the manifest for the given app host service, and caches the result.

func (*DotNetImporter) Services

func (ai *DotNetImporter) Services(
	ctx context.Context, p *ProjectConfig, svcConfig *ServiceConfig,
) (map[string]*ServiceConfig, error)

func (*DotNetImporter) SynthAllInfrastructure

func (ai *DotNetImporter) SynthAllInfrastructure(
	ctx context.Context, p *ProjectConfig, svcConfig *ServiceConfig,
) (fs.FS, error)

type FrameworkPackageRequirements

type FrameworkPackageRequirements struct {
	RequireRestore bool
	RequireBuild   bool
}

type FrameworkRequirements

type FrameworkRequirements struct {
	Package FrameworkPackageRequirements
}

type FrameworkService

type FrameworkService interface {
	// Gets a list of the required external tools for the framework service
	RequiredExternalTools(ctx context.Context) []tools.ExternalTool

	// Initializes the framework service for the specified service configuration
	// This is useful if the framework needs to subscribe to any service events
	Initialize(ctx context.Context, serviceConfig *ServiceConfig) error

	// Gets the requirements for the language or framework service.
	// This enables more fine grain control on whether the language / framework
	// supports or requires lifecycle commands such as restore, build, and package
	Requirements() FrameworkRequirements

	// Restores dependencies for the framework service
	Restore(
		ctx context.Context,
		serviceConfig *ServiceConfig,
	) *async.TaskWithProgress[*ServiceRestoreResult, ServiceProgress]

	// Builds the source for the framework service
	Build(
		ctx context.Context,
		serviceConfig *ServiceConfig,
		restoreOutput *ServiceRestoreResult,
	) *async.TaskWithProgress[*ServiceBuildResult, ServiceProgress]

	// Packages the source suitable for deployment
	// This may optionally perform a rebuild internally depending on the language/framework requirements
	Package(
		ctx context.Context,
		serviceConfig *ServiceConfig,
		buildOutput *ServiceBuildResult,
	) *async.TaskWithProgress[*ServicePackageResult, ServiceProgress]
}

FrameworkService is an abstraction for a programming language or framework that describe the required tools as well as implementations for restore and build commands

func NewDockerProjectAsFrameworkService

func NewDockerProjectAsFrameworkService(
	env *environment.Environment,
	docker docker.Docker,
	containerHelper *ContainerHelper,
	console input.Console,
	alphaFeatureManager *alpha.FeatureManager,
	commandRunner exec.CommandRunner,
) FrameworkService

NewDockerProjectAsFrameworkService is the same as NewDockerProject().(FrameworkService) and exists to support our use of DI and ServiceLocators, where we sometimes need to resolve this type as a FrameworkService instance instead of a CompositeFrameworkService as NewDockerProject does.

func NewDotNetProject

func NewDotNetProject(
	dotNetCli dotnet.DotNetCli,
	env *environment.Environment,
) FrameworkService

NewDotNetProject creates a new instance of a dotnet project

func NewMavenProject

func NewMavenProject(env *environment.Environment, mavenCli maven.MavenCli, javaCli javac.JavacCli) FrameworkService

NewMavenProject creates a new instance of a maven project

func NewNoOpProject

func NewNoOpProject(env *environment.Environment) FrameworkService

NewNoOpProject creates a new instance of a no-op project, which implements the FrameworkService interface but does not perform any actions.

func NewNpmProject

func NewNpmProject(cli npm.NpmCli, env *environment.Environment) FrameworkService

NewNpmProject creates a new instance of a NPM project

func NewPythonProject

func NewPythonProject(cli *python.PythonCli, env *environment.Environment) FrameworkService

NewPythonProject creates a new instance of the Python project

type ImportManager

type ImportManager struct {
	// contains filtered or unexported fields
}

func NewImportManager

func NewImportManager(dotNetImporter *DotNetImporter) *ImportManager

func (*ImportManager) HasService

func (im *ImportManager) HasService(ctx context.Context, projectConfig *ProjectConfig, name string) (bool, error)

func (*ImportManager) ProjectInfrastructure

func (im *ImportManager) ProjectInfrastructure(ctx context.Context, projectConfig *ProjectConfig) (*Infra, error)

ProjectInfrastructure parses the project configuration and returns the infrastructure configuration. The configuration can be explicitly defined on azure.yaml using path and module, or in case these values are not explicitly defined, the project importer uses default values to find the infrastructure.

func (*ImportManager) ServiceStable

func (im *ImportManager) ServiceStable(ctx context.Context, projectConfig *ProjectConfig) ([]*ServiceConfig, error)

Retrieves the list of services in the project, in a stable ordering that is deterministic.

func (*ImportManager) SynthAllInfrastructure

func (im *ImportManager) SynthAllInfrastructure(ctx context.Context, projectConfig *ProjectConfig) (fs.FS, error)

type Infra

type Infra struct {
	Options provisioning.Options
	// contains filtered or unexported fields
}

Infra represents the (possibly temporarily generated) infrastructure. Call [Cleanup] when done with infrastructure, which will cause any temporarily generated files to be removed.

func (*Infra) Cleanup

func (i *Infra) Cleanup() error

type PackageOptions

type PackageOptions struct {
	OutputPath string
}

type PipelineOptions

type PipelineOptions struct {
	Provider  string   `yaml:"provider"`
	Variables []string `yaml:"variables"`
	Secrets   []string `yaml:"secrets"`
}

options supported in azure.yaml

type ProjectConfig

type ProjectConfig struct {
	RequiredVersions  *RequiredVersions          `yaml:"requiredVersions,omitempty"`
	Name              string                     `yaml:"name"`
	ResourceGroupName osutil.ExpandableString    `yaml:"resourceGroup,omitempty"`
	Path              string                     `yaml:"-"`
	Metadata          *ProjectMetadata           `yaml:"metadata,omitempty"`
	Services          map[string]*ServiceConfig  `yaml:"services,omitempty"`
	Infra             provisioning.Options       `yaml:"infra,omitempty"`
	Pipeline          PipelineOptions            `yaml:"pipeline,omitempty"`
	Hooks             map[string]*ext.HookConfig `yaml:"hooks,omitempty"`
	State             *state.Config              `yaml:"state,omitempty"`
	Platform          *platform.Config           `yaml:"platform,omitempty"`
	Workflows         workflow.WorkflowMap       `yaml:"workflows,omitempty"`
	Cloud             *cloud.Config              `yaml:"cloud,omitempty"`

	*ext.EventDispatcher[ProjectLifecycleEventArgs] `yaml:"-"`
}

ProjectConfig is the top level object serialized into an azure.yaml file. When changing project structure, make sure to update the JSON schema file for azure.yaml (<workspace root>/schemas/vN.M/azure.yaml.json).

func Load

func Load(ctx context.Context, projectFilePath string) (*ProjectConfig, error)

Load hydrates the azure.yaml configuring into an viewable structure This does not evaluate any tooling

func New

func New(ctx context.Context, projectFilePath string, projectName string) (*ProjectConfig, error)

func Parse

func Parse(ctx context.Context, yamlContent string) (*ProjectConfig, error)

Parse will parse a project from a yaml string and return the project configuration

type ProjectLifecycleEventArgs

type ProjectLifecycleEventArgs struct {
	Project *ProjectConfig
	Args    map[string]any
}

Project lifecycle event arguments

type ProjectLifecycleEventHandlerFn

type ProjectLifecycleEventHandlerFn func(ctx context.Context, args ProjectLifecycleEventArgs) error

Function definition for project events

type ProjectManager

type ProjectManager interface {
	// Initializes the project and all child services defined within the project configuration
	//
	// The initialization process will instantiate the framework & service target associated
	// with the service config that enables the scenario for these components to add event
	// handlers to participate in the lifecycle of an azd project
	//
	// The initialization process will also ensure that all required tools are installed
	Initialize(ctx context.Context, projectConfig *ProjectConfig) error

	// Returns the default service name to target based on the current working directory.
	//
	//   - If the working directory is the project directory, then an empty string is returned to indicate all services.
	//   - If the working directory is a service directory, then the name of the service is returned.
	//   - If the working directory is neither the project directory nor a service directory, then
	//     ErrNoDefaultService is returned.
	DefaultServiceFromWd(ctx context.Context, projectConfig *ProjectConfig) (serviceConfig *ServiceConfig, err error)

	// Ensures that all required tools are installed for the project and all child services
	// This includes tools required by the framework and tools required by the service target
	EnsureAllTools(ctx context.Context, projectConfig *ProjectConfig, serviceFilterFn ServiceFilterPredicate) error

	// Ensures that all required framework tools are installed for the project and all child services
	EnsureFrameworkTools(ctx context.Context, projectConfig *ProjectConfig, serviceFilterFn ServiceFilterPredicate) error

	// Ensures that all required service target tools are installed for the project and all child services
	EnsureServiceTargetTools(ctx context.Context, projectConfig *ProjectConfig, serviceFilterFn ServiceFilterPredicate) error
}

ProjectManager provides a layer for working with root level azd projects and invoking project specific commands

func NewProjectManager

func NewProjectManager(
	azdContext *azdcontext.AzdContext,
	serviceManager ServiceManager,
	importManager *ImportManager,
) ProjectManager

NewProjectManager creates a new instance of the ProjectManager

type ProjectMetadata

type ProjectMetadata struct {
	// Template is a slug that identifies the template and a version. This attribute should be
	// in every template that we ship.
	// ex: todo-python-mongo@version
	Template string
}

type RequiredVersions

type RequiredVersions struct {
	// When non nil, a semver range (in the format expected by semver.ParseRange).
	Azd *string `yaml:"azd,omitempty"`
}

RequiredVersions contains information about what versions of tools this project requires. If a value is nil, it is treated as if there is no constraint.

type ResourceManager

type ResourceManager interface {
	GetResourceGroupName(ctx context.Context, subscriptionId string, projectConfig *ProjectConfig) (string, error)
	GetServiceResources(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		serviceConfig *ServiceConfig,
	) ([]azcli.AzCliResource, error)
	GetServiceResource(
		ctx context.Context,
		subscriptionId string,
		resourceGroupName string,
		serviceConfig *ServiceConfig,
		rerunCommand string,
	) (azcli.AzCliResource, error)
	GetTargetResource(
		ctx context.Context,
		subscriptionId string,
		serviceConfig *ServiceConfig,
	) (*environment.TargetResource, error)
}

ResourceManager provides a layer to query for Azure resource for azd project and services This would typically be used during deployment when azd need to deploy applications to the Azure resource hosting the application

func NewResourceManager

func NewResourceManager(
	env *environment.Environment,
	azCli azcli.AzCli,
	deploymentOperations azapi.DeploymentOperations) ResourceManager

NewResourceManager creates a new instance of the project resource manager

type ServiceBuildResult

type ServiceBuildResult struct {
	Restore         *ServiceRestoreResult `json:"restore"`
	BuildOutputPath string                `json:"buildOutputPath"`
	Details         interface{}           `json:"details"`
}

ServiceBuildResult is the result of a successful Build operation

func (*ServiceBuildResult) MarshalJSON

func (sbr *ServiceBuildResult) MarshalJSON() ([]byte, error)

func (*ServiceBuildResult) ToString

func (sbr *ServiceBuildResult) ToString(currentIndentation string) string

Supports rendering messages for UX items

type ServiceConfig

type ServiceConfig struct {
	// Reference to the parent project configuration
	Project *ProjectConfig `yaml:"-"`
	// The friendly name/key of the project from the azure.yaml file
	Name string `yaml:"-"`
	// The name used to override the default azure resource name
	ResourceName osutil.ExpandableString `yaml:"resourceName,omitempty"`
	// The relative path to the project folder from the project root
	RelativePath string `yaml:"project"`
	// The azure hosting model to use, ex) appservice, function, containerapp
	Host ServiceTargetKind `yaml:"host"`
	// The programming language of the project
	Language ServiceLanguageKind `yaml:"language"`
	// The output path for build artifacts
	OutputPath string `yaml:"dist,omitempty"`
	// The source image to use for container based applications
	Image string `yaml:"image,omitempty"`
	// The optional docker options for configuring the output image
	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"`
	// The infrastructure provisioning configuration
	Infra provisioning.Options `yaml:"infra,omitempty"`
	// Hook configuration for service
	Hooks map[string]*ext.HookConfig `yaml:"hooks,omitempty"`
	// Options specific to the DotNetContainerApp target. These are set by the importer and
	// can not be controlled via the project file today.
	DotNetContainerApp *DotNetContainerAppOptions `yaml:"-,omitempty"`
	// Custom configuration for the service target
	Config map[string]any `yaml:"config,omitempty"`

	*ext.EventDispatcher[ServiceLifecycleEventArgs] `yaml:"-"`
}

func (*ServiceConfig) Path

func (sc *ServiceConfig) Path() string

Path returns the fully qualified path to the project

type ServiceDeployResult

type ServiceDeployResult struct {
	Package *ServicePackageResult `json:"package"`
	// Related Azure resource ID
	TargetResourceId string            `json:"targetResourceId"`
	Kind             ServiceTargetKind `json:"kind"`
	Endpoints        []string          `json:"endpoints"`
	Details          interface{}       `json:"details"`
}

ServiceDeployResult is the result of a successful Deploy operation

func NewServiceDeployResult

func NewServiceDeployResult(
	relatedResourceId string,
	kind ServiceTargetKind,
	rawResult string,
	endpoints []string,
) *ServiceDeployResult

NewServiceDeployResult is a helper function to create a new ServiceDeployResult

func (*ServiceDeployResult) MarshalJSON

func (spr *ServiceDeployResult) MarshalJSON() ([]byte, error)

func (*ServiceDeployResult) ToString

func (spr *ServiceDeployResult) ToString(currentIndentation string) string

Supports rendering messages for UX items

type ServiceFilterPredicate

type ServiceFilterPredicate func(svc *ServiceConfig) bool

ServiceFilterPredicate is a function that can be used to filter services that match a given criteria

type ServiceLanguageKind

type ServiceLanguageKind string
const (
	ServiceLanguageNone       ServiceLanguageKind = ""
	ServiceLanguageDotNet     ServiceLanguageKind = "dotnet"
	ServiceLanguageCsharp     ServiceLanguageKind = "csharp"
	ServiceLanguageFsharp     ServiceLanguageKind = "fsharp"
	ServiceLanguageJavaScript ServiceLanguageKind = "js"
	ServiceLanguageTypeScript ServiceLanguageKind = "ts"
	ServiceLanguagePython     ServiceLanguageKind = "python"
	ServiceLanguageJava       ServiceLanguageKind = "java"
	ServiceLanguageDocker     ServiceLanguageKind = "docker"
)

type ServiceLifecycleEventArgs

type ServiceLifecycleEventArgs struct {
	Project *ProjectConfig
	Service *ServiceConfig
	Args    map[string]any
}

ServiceLifecycleEventArgs are the event arguments available when any service lifecycle event has been triggered

type ServiceManager

type ServiceManager interface {
	// Gets all of the required framework/service target tools for the specified service config
	GetRequiredTools(ctx context.Context, serviceConfig *ServiceConfig) ([]tools.ExternalTool, error)

	// Initializes the service configuration and dependent framework & service target
	// This allows frameworks & service targets to hook into a services lifecycle events
	Initialize(ctx context.Context, serviceConfig *ServiceConfig) error

	// Restores the code dependencies for the specified service config
	Restore(
		ctx context.Context,
		serviceConfig *ServiceConfig,
	) *async.TaskWithProgress[*ServiceRestoreResult, ServiceProgress]

	// Builds the code for the specified service config
	// Will call the language compile for compiled languages or
	// may copy build artifacts to a configured output folder
	Build(
		ctx context.Context,
		serviceConfig *ServiceConfig,
		restoreOutput *ServiceRestoreResult,
	) *async.TaskWithProgress[*ServiceBuildResult, ServiceProgress]

	// Packages the code for the specified service config
	// Depending on the service configuration this will generate an artifact
	// that can be consumed by the hosting Azure service.
	// Common examples could be a zip archive for app service or
	// Docker images for container apps and AKS
	Package(
		ctx context.Context,
		serviceConfig *ServiceConfig,
		buildOutput *ServiceBuildResult,
		options *PackageOptions,
	) *async.TaskWithProgress[*ServicePackageResult, ServiceProgress]

	// Deploys the generated artifacts to the Azure resource that will
	// host the service application
	// Common examples would be uploading zip archive using ZipDeploy deployment or
	// pushing container images to a container registry.
	Deploy(
		ctx context.Context,
		serviceConfig *ServiceConfig,
		packageOutput *ServicePackageResult,
	) *async.TaskWithProgress[*ServiceDeployResult, ServiceProgress]

	// Gets the framework service for the specified service config
	// The framework service performs the restoration and building of the service app code
	GetFrameworkService(ctx context.Context, serviceConfig *ServiceConfig) (FrameworkService, error)

	// Gets the service target service for the specified service config
	// The service target is responsible for packaging & deploying the service app code
	// to the destination Azure resource
	GetServiceTarget(ctx context.Context, serviceConfig *ServiceConfig) (ServiceTarget, error)
}

ServiceManager provides a management layer for performing operations against an azd service within a project The component performs all of the heavy lifting for executing all lifecycle operations for a service.

All service lifecycle command leverage our async Task library to expose a common interface for handling long running operations including how we handle incremental progress updates and error handling.

func NewServiceManager

func NewServiceManager(
	env *environment.Environment,
	resourceManager ResourceManager,
	serviceLocator ioc.ServiceLocator,
	operationCache ServiceOperationCache,
	alphaFeatureManager *alpha.FeatureManager,
) ServiceManager

NewServiceManager creates a new instance of the ServiceManager component

type ServiceOperationCache

type ServiceOperationCache map[string]any

ServiceOperationCache is an alias to map used for internal caching of service operation results The ServiceManager is a scoped component since it depends on the current environment The ServiceOperationCache is used as a singleton cache for all service manager instances

type ServicePackageResult

type ServicePackageResult struct {
	Build       *ServiceBuildResult `json:"build"`
	PackagePath string              `json:"packagePath"`
	Details     interface{}         `json:"details"`
}

ServicePackageResult is the result of a successful Package operation

func (*ServicePackageResult) MarshalJSON

func (spr *ServicePackageResult) MarshalJSON() ([]byte, error)

func (*ServicePackageResult) ToString

func (spr *ServicePackageResult) ToString(currentIndentation string) string

Supports rendering messages for UX items

type ServiceProgress

type ServiceProgress struct {
	Message   string
	Timestamp time.Time
}

ServiceProgress represents an incremental progress message during a service operation such as restore, build, package & deploy

func NewServiceProgress

func NewServiceProgress(message string) ServiceProgress

NewServiceProgress is a helper method to create a new progress message with a current timestamp

type ServiceRestoreResult

type ServiceRestoreResult struct {
	Details interface{} `json:"details"`
}

ServiceRestoreResult is the result of a successful Restore operation

type ServiceTarget

type ServiceTarget interface {
	// Initializes the service target for the specified service configuration.
	// This allows service targets to opt-in to service lifecycle events
	Initialize(ctx context.Context, serviceConfig *ServiceConfig) error

	// RequiredExternalTools are the tools needed to run the deploy operation for this
	// target.
	RequiredExternalTools(ctx context.Context) []tools.ExternalTool

	// Package prepares artifacts for deployment
	Package(
		ctx context.Context,
		serviceConfig *ServiceConfig,
		frameworkPackageOutput *ServicePackageResult,
	) *async.TaskWithProgress[*ServicePackageResult, ServiceProgress]

	// Deploys the given deployment artifact to the target resource
	Deploy(
		ctx context.Context,
		serviceConfig *ServiceConfig,
		servicePackage *ServicePackageResult,
		targetResource *environment.TargetResource,
	) *async.TaskWithProgress[*ServiceDeployResult, ServiceProgress]

	// Endpoints gets the endpoints a service exposes.
	Endpoints(
		ctx context.Context,
		serviceConfig *ServiceConfig,
		targetResource *environment.TargetResource,
	) ([]string, error)
}

func NewAiEndpointTarget

func NewAiEndpointTarget(
	env *environment.Environment,
	envManager environment.Manager,
	aiHelper AiHelper,
) ServiceTarget

NewAiEndpointTarget creates a new aiEndpointTarget instance

func NewAksTarget

func NewAksTarget(
	env *environment.Environment,
	envManager environment.Manager,
	console input.Console,
	managedClustersService azcli.ManagedClustersService,
	resourceManager ResourceManager,
	kubectlCli kubectl.KubectlCli,
	kubeLoginCli *kubelogin.Cli,
	helmCli *helm.Cli,
	kustomizeCli *kustomize.Cli,
	containerHelper *ContainerHelper,
	featureManager *alpha.FeatureManager,
) ServiceTarget

Creates a new instance of the AKS service target

func NewAppServiceTarget

func NewAppServiceTarget(
	env *environment.Environment,
	azCli azcli.AzCli,
) ServiceTarget

NewAppServiceTarget creates a new instance of the AppServiceTarget

func NewContainerAppTarget

func NewContainerAppTarget(
	env *environment.Environment,
	envManager environment.Manager,
	containerHelper *ContainerHelper,
	containerAppService containerapps.ContainerAppService,
	resourceManager ResourceManager,
) ServiceTarget

NewContainerAppTarget creates the container app service target.

The target resource can be partially filled with only ResourceGroupName, since container apps can be provisioned during deployment.

func NewDotNetContainerAppTarget

func NewDotNetContainerAppTarget(
	env *environment.Environment,
	containerHelper *ContainerHelper,
	containerAppService containerapps.ContainerAppService,
	resourceManager ResourceManager,
	dotNetCli dotnet.DotNetCli,
	cosmosDbService cosmosdb.CosmosDbService,
	sqlDbService sqldb.SqlDbService,
	keyvaultService keyvault.KeyVaultService,
	alphaFeatureManager *alpha.FeatureManager,
) ServiceTarget

NewDotNetContainerAppTarget creates the Service Target for a Container App that is written in .NET. Unlike ContainerAppTarget, this target does not require a Dockerfile to be present in the project. Instead, it uses the built in support in .NET 8 for publishing containers using `dotnet publish`. In addition, it uses a different deployment strategy built on a yaml manifest file, using the same format `az containerapp create --yaml`, with additional support for using text/template to do replacements, similar to tools like Helm.

Note that unlike ContainerAppTarget this target does not add SERVICE_<XYZ>_IMAGE_NAME values to the environment, instead, the image name is present on the context object used when rendering the template.

func NewFunctionAppTarget

func NewFunctionAppTarget(
	env *environment.Environment,
	azCli azcli.AzCli,
) ServiceTarget

NewFunctionAppTarget creates a new instance of the Function App target

func NewSpringAppTarget

func NewSpringAppTarget(
	env *environment.Environment,
	envManager environment.Manager,
	springService azcli.SpringService,
) ServiceTarget

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 NewStaticWebAppTarget

func NewStaticWebAppTarget(
	env *environment.Environment,
	azCli azcli.AzCli,
	swaCli swa.SwaCli,
) ServiceTarget

NewStaticWebAppTarget creates a new instance of the Static Web App target

type ServiceTargetKind

type ServiceTargetKind string
const (
	NonSpecifiedTarget       ServiceTargetKind = ""
	AppServiceTarget         ServiceTargetKind = "appservice"
	ContainerAppTarget       ServiceTargetKind = "containerapp"
	AzureFunctionTarget      ServiceTargetKind = "function"
	StaticWebAppTarget       ServiceTargetKind = "staticwebapp"
	SpringAppTarget          ServiceTargetKind = "springapp"
	AksTarget                ServiceTargetKind = "aks"
	DotNetContainerAppTarget ServiceTargetKind = "containerapp-dotnet"
	AiEndpointTarget         ServiceTargetKind = "ai.endpoint"
)

func (ServiceTargetKind) RequiresContainer

func (stk ServiceTargetKind) RequiresContainer() bool

RequiresContainer returns true if the service target runs a container image.

func (ServiceTargetKind) SupportsDelayedProvisioning

func (st ServiceTargetKind) SupportsDelayedProvisioning() bool

SupportsDelayedProvisioning returns true if the service target kind supports delayed provisioning resources at deployment time, otherwise false.

As an example, ContainerAppTarget is able to provision the container app as part of deployment, and thus returns true.

type SpringOptions

type SpringOptions struct {
	// The deployment name of ASA app
	DeploymentName string `yaml:"deploymentName"`
}

The Azure Spring Apps configuration options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL