builderIDistributedApplicationBuilderThe builder for the distributed application.
namestringThe name of the resource.
Returns
IResourceBuilder<AzurePostgresFlexibleServerResource> A reference to the ApplicationModel.IResourceBuilder`1 builder.
Remarks
By default, the Azure PostgreSQL Flexible Server resource is configured to use Microsoft Entra ID (Azure Active Directory) for authentication. This requires changes to the application code to use an azure credential to authenticate with the resource. See https://learn.microsoft.com/azure/postgresql/flexible-server/how-to-connect-with-managed-identity#connect-using-managed-identity-in-c for more information. You can use the AzurePostgresExtensions.WithPasswordAuthentication method to configure the resource to use password authentication. The following example creates an Azure PostgreSQL Flexible Server resource and referencing that resource in a .NET project.
var builder =DistributedApplication.CreateBuilder(args);
var data =builder.AddAzurePostgresFlexibleServer("data");
builderIResourceBuilder<AzurePostgresFlexibleServerResource>The Azure PostgreSQL server resource builder.
configureContainerAction<IResourceBuilder<PostgresServerResource>>optionalCallback that exposes underlying container to allow for customization.
Returns
IResourceBuilder<AzurePostgresFlexibleServerResource> A reference to the ApplicationModel.IResourceBuilder`1 builder.
Remarks
The following example creates an Azure PostgreSQL Flexible Server resource that runs locally in a PostgreSQL container and referencing that resource in a .NET project.
var builder =DistributedApplication.CreateBuilder(args);
var data =builder.AddAzurePostgresFlexibleServer("data")
builderIResourceBuilder<AzurePostgresFlexibleServerResource>The Azure PostgreSQL server resource builder.
userNameIResourceBuilder<ParameterResource>optionalThe parameter used to provide the user name for the PostgreSQL resource. If null a default value will be used.
passwordIResourceBuilder<ParameterResource>optionalThe parameter used to provide the administrator password for the PostgreSQL resource. If null a random password will be generated.
Returns
IResourceBuilder<AzurePostgresFlexibleServerResource> A reference to the ApplicationModel.IResourceBuilder`1 builder.
Remarks
The following example creates an Azure PostgreSQL Flexible Server resource that uses password authentication.
var builder =DistributedApplication.CreateBuilder(args);
var data =builder.AddAzurePostgresFlexibleServer("data")
Configures the resource to use password authentication for Azure PostgreSQL Flexible Server. This overload is used when the PostgreSQL resource is created in a container and the password is stored in an Azure Key Vault secret.
userNameIResourceBuilder<ParameterResource>optionalThe parameter used to provide the user name for the PostgreSQL resource. If null a default value will be used.
passwordIResourceBuilder<ParameterResource>optionalThe parameter used to provide the administrator password for the PostgreSQL resource. If null a random password will be generated.
Returns
IResourceBuilder<AzurePostgresFlexibleServerResource> A reference to the ApplicationModel.IResourceBuilder`1 builder.