Condividi tramite


AzureSqlExtensions.RunAsContainer Method

Definition

Configures an Azure SQL Database (server) resource to run locally in a container.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureSqlServerResource> RunAsContainer (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureSqlServerResource> builder, Action<Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.SqlServerServerResource>>? configureContainer = default);
static member RunAsContainer : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureSqlServerResource> * Action<Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.SqlServerServerResource>> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureSqlServerResource>
<Extension()>
Public Function RunAsContainer (builder As IResourceBuilder(Of AzureSqlServerResource), Optional configureContainer As Action(Of IResourceBuilder(Of SqlServerServerResource)) = Nothing) As IResourceBuilder(Of AzureSqlServerResource)

Parameters

builder
IResourceBuilder<AzureSqlServerResource>

The builder for the Azure SQL resource.

configureContainer
Action<IResourceBuilder<SqlServerServerResource>>

Callback that exposes underlying container to allow for customization.

Returns

A reference to the IResourceBuilder<T> builder.

Examples

The following example creates an Azure SQL Database (server) resource that runs locally in a SQL Server container and referencing that resource in a .NET project.

var builder = DistributedApplication.CreateBuilder(args);

var data = builder.AddAzureSqlServer("data")
    .RunAsContainer();

builder.AddProject<Projects.ProductService>()
    .WithReference(data);

builder.Build().Run();

Applies to