Partager via


AzurePostgresExtensions.WithPasswordAuthentication Method

Definition

Configures the resource to use password authentication for Azure PostgreSQL Flexible Server.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzurePostgresFlexibleServerResource> WithPasswordAuthentication (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzurePostgresFlexibleServerResource> builder, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource>? userName = default, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource>? password = default);
static member WithPasswordAuthentication : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzurePostgresFlexibleServerResource> * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzurePostgresFlexibleServerResource>
<Extension()>
Public Function WithPasswordAuthentication (builder As IResourceBuilder(Of AzurePostgresFlexibleServerResource), Optional userName As IResourceBuilder(Of ParameterResource) = Nothing, Optional password As IResourceBuilder(Of ParameterResource) = Nothing) As IResourceBuilder(Of AzurePostgresFlexibleServerResource)

Parameters

builder
IResourceBuilder<AzurePostgresFlexibleServerResource>

The Azure PostgreSQL server resource builder.

userName
IResourceBuilder<ParameterResource>

The parameter used to provide the user name for the PostgreSQL resource. If null a default value will be used.

password
IResourceBuilder<ParameterResource>

The parameter used to provide the administrator password for the PostgreSQL resource. If null a random password will be generated.

Returns

A reference to the IResourceBuilder<T> builder.

Examples

The following example creates an Azure PostgreSQL Flexible Server resource that uses password authentication.

var builder = DistributedApplication.CreateBuilder(args);

var data = builder.AddAzurePostgresFlexibleServer("data")
    .WithPasswordAuthentication();

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

builder.Build().Run();

Applies to