更新现有服务器。 请求正文可以包含常规服务器定义中存在的一个或多个属性。
PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}?api-version=2024-08-01
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
资源组的名称。 此名称不区分大小写。
|
serverName
|
path |
True
|
string
minLength: 3 maxLength: 63 pattern: ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*
|
服务器的名称。
|
subscriptionId
|
path |
True
|
string
(uuid)
|
目标订阅的 ID。 该值必须是 UUID。
|
api-version
|
query |
True
|
string
minLength: 1
|
用于此操作的 API 版本。
|
请求正文
响应
名称 |
类型 |
说明 |
200 OK
|
Server
|
好的
|
202 Accepted
|
|
已接受
标头
Location: string
|
Other Status Codes
|
ErrorResponse
|
描述作失败的原因的错误响应。
|
安全性
azure_auth
Microsoft Entra OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"properties": {
"replica": {
"promoteMode": "standalone",
"promoteOption": "forced"
}
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.ReadReplicaPromoteMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Replica;
import com.azure.resourcemanager.postgresqlflexibleserver.models.ReplicationPromoteOption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Server;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers Update.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* PromoteReplicaAsForcedStandaloneServer.json
*/
/**
* Sample code: Promote a replica server as a Standalone server as forced, i.e. it will promote a replica server
* immediately without waiting for primary and replica to be in sync.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
promoteAReplicaServerAsAStandaloneServerAsForcedIEItWillPromoteAReplicaServerImmediatelyWithoutWaitingForPrimaryAndReplicaToBeInSync(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
Server resource = manager.servers()
.getByResourceGroupWithResponse("testResourceGroup", "pgtestsvc4-replica", com.azure.core.util.Context.NONE)
.getValue();
resource.update().withReplica(new Replica().withPromoteMode(ReadReplicaPromoteMode.STANDALONE)
.withPromoteOption(ReplicationPromoteOption.FORCED)).apply();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python promote_replica_as_forced_standalone_server.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_update(
resource_group_name="testResourceGroup",
server_name="pgtestsvc4-replica",
parameters={"properties": {"replica": {"promoteMode": "standalone", "promoteOption": "forced"}}},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsForcedStandaloneServer.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsForcedStandaloneServer.json
func ExampleServersClient_BeginUpdate_promoteAReplicaServerAsAStandaloneServerAsForcedIEItWillPromoteAReplicaServerImmediatelyWithoutWaitingForPrimaryAndReplicaToBeInSync() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testResourceGroup", "pgtestsvc4-replica", armpostgresqlflexibleservers.ServerForUpdate{
Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{
Replica: &armpostgresqlflexibleservers.Replica{
PromoteMode: to.Ptr(armpostgresqlflexibleservers.ReadReplicaPromoteModeStandalone),
PromoteOption: to.Ptr(armpostgresqlflexibleservers.ReplicationPromoteOptionForced),
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Server = armpostgresqlflexibleservers.Server{
// Name: to.Ptr("pgtestsvc4-replica"),
// Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4-replica"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "ElasticServer": to.Ptr("1"),
// },
// Properties: &armpostgresqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
// ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumDisabled),
// PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
// },
// AvailabilityZone: to.Ptr("1"),
// Backup: &armpostgresqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](20),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-26T01:16:58.372Z"); return t}()),
// GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled),
// },
// DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
// Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeSystemManaged),
// },
// FullyQualifiedDomainName: to.Ptr("pgtestsvc4-replica.postgres.database.azure.com"),
// HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("2"),
// State: to.Ptr(armpostgresqlflexibleservers.ServerHAStateHealthy),
// },
// MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// MinorVersion: to.Ptr("6"),
// Network: &armpostgresqlflexibleservers.Network{
// DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"),
// PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"),
// PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateDisabled),
// },
// Replica: &armpostgresqlflexibleservers.Replica{
// Capacity: to.Ptr[int32](0),
// Role: to.Ptr(armpostgresqlflexibleservers.ReplicationRoleNone),
// },
// State: to.Ptr(armpostgresqlflexibleservers.ServerStateReady),
// Storage: &armpostgresqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowEnabled),
// Iops: to.Ptr[int32](5000),
// StorageSizeGB: to.Ptr[int32](1024),
// Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTiersP30),
// },
// Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve),
// },
// SKU: &armpostgresqlflexibleservers.SKU{
// Name: to.Ptr("Standard_D8s_v3"),
// Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
*
* @summary Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsForcedStandaloneServer.json
*/
async function promoteAReplicaServerAsAStandaloneServerAsForcedIEItWillPromoteAReplicaServerImmediatelyWithoutWaitingForPrimaryAndReplicaToBeInSync() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testResourceGroup";
const serverName = "pgtestsvc4-replica";
const parameters = {
replica: { promoteMode: "standalone", promoteOption: "forced" },
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginUpdateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsForcedStandaloneServer.json
// this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testResourceGroup";
string serverName = "pgtestsvc4-replica";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// invoke the operation
PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch()
{
Replica = new PostgreSqlFlexibleServersReplica()
{
PromoteMode = ReadReplicaPromoteMode.Standalone,
PromoteOption = ReplicationPromoteOption.Forced,
},
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Enabled",
"tier": "P30",
"iops": 5000
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2024-08-01T18:35:22.123456Z"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"replica": {
"role": "None",
"capacity": 0
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"properties": {
"replica": {
"promoteMode": "standalone",
"promoteOption": "planned"
}
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.ReadReplicaPromoteMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Replica;
import com.azure.resourcemanager.postgresqlflexibleserver.models.ReplicationPromoteOption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Server;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers Update.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* PromoteReplicaAsPlannedStandaloneServer.json
*/
/**
* Sample code: Promote a replica server as a Standalone server as planned, i.e. it will wait for replication to
* complete.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void promoteAReplicaServerAsAStandaloneServerAsPlannedIEItWillWaitForReplicationToComplete(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
Server resource = manager.servers()
.getByResourceGroupWithResponse("testResourceGroup", "pgtestsvc4-replica", com.azure.core.util.Context.NONE)
.getValue();
resource.update().withReplica(new Replica().withPromoteMode(ReadReplicaPromoteMode.STANDALONE)
.withPromoteOption(ReplicationPromoteOption.PLANNED)).apply();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python promote_replica_as_planned_standalone_server.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_update(
resource_group_name="testResourceGroup",
server_name="pgtestsvc4-replica",
parameters={"properties": {"replica": {"promoteMode": "standalone", "promoteOption": "planned"}}},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsPlannedStandaloneServer.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsPlannedStandaloneServer.json
func ExampleServersClient_BeginUpdate_promoteAReplicaServerAsAStandaloneServerAsPlannedIEItWillWaitForReplicationToComplete() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testResourceGroup", "pgtestsvc4-replica", armpostgresqlflexibleservers.ServerForUpdate{
Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{
Replica: &armpostgresqlflexibleservers.Replica{
PromoteMode: to.Ptr(armpostgresqlflexibleservers.ReadReplicaPromoteModeStandalone),
PromoteOption: to.Ptr(armpostgresqlflexibleservers.ReplicationPromoteOptionPlanned),
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Server = armpostgresqlflexibleservers.Server{
// Name: to.Ptr("pgtestsvc4-replica"),
// Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4-replica"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "ElasticServer": to.Ptr("1"),
// },
// Properties: &armpostgresqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
// ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumDisabled),
// PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
// },
// AvailabilityZone: to.Ptr("1"),
// Backup: &armpostgresqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](20),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-26T01:16:58.372Z"); return t}()),
// GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled),
// },
// DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
// Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeSystemManaged),
// },
// FullyQualifiedDomainName: to.Ptr("pgtestsvc4-replica.postgres.database.azure.com"),
// HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("2"),
// State: to.Ptr(armpostgresqlflexibleservers.ServerHAStateHealthy),
// },
// MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// MinorVersion: to.Ptr("6"),
// Network: &armpostgresqlflexibleservers.Network{
// DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"),
// PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"),
// PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateDisabled),
// },
// Replica: &armpostgresqlflexibleservers.Replica{
// Capacity: to.Ptr[int32](0),
// Role: to.Ptr(armpostgresqlflexibleservers.ReplicationRoleNone),
// },
// State: to.Ptr(armpostgresqlflexibleservers.ServerStateReady),
// Storage: &armpostgresqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowEnabled),
// Iops: to.Ptr[int32](5000),
// StorageSizeGB: to.Ptr[int32](1024),
// Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTiersP30),
// },
// Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve),
// },
// SKU: &armpostgresqlflexibleservers.SKU{
// Name: to.Ptr("Standard_D8s_v3"),
// Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
*
* @summary Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsPlannedStandaloneServer.json
*/
async function promoteAReplicaServerAsAStandaloneServerAsPlannedIEItWillWaitForReplicationToComplete() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testResourceGroup";
const serverName = "pgtestsvc4-replica";
const parameters = {
replica: { promoteMode: "standalone", promoteOption: "planned" },
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginUpdateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsPlannedStandaloneServer.json
// this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testResourceGroup";
string serverName = "pgtestsvc4-replica";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// invoke the operation
PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch()
{
Replica = new PostgreSqlFlexibleServersReplica()
{
PromoteMode = ReadReplicaPromoteMode.Standalone,
PromoteOption = ReplicationPromoteOption.Planned,
},
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Enabled",
"tier": "P30",
"iops": 5000
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2025-02-26T01:16:58.3723361+00:00"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"replica": {
"role": "None",
"capacity": 0
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Switch over a read replica to primary server with forced data synchronization. Meaning that it doesn't wait for data in the read replica to be synchronized with its source server before it initiates the switching of roles between the read replica and the primary server.
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"properties": {
"replica": {
"promoteMode": "switchover",
"promoteOption": "forced"
}
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.ReadReplicaPromoteMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Replica;
import com.azure.resourcemanager.postgresqlflexibleserver.models.ReplicationPromoteOption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Server;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers Update.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* PromoteReplicaAsForcedSwitchover.json
*/
/**
* Sample code: SwitchOver a replica server as forced, i.e. it will replica as Primary and original primary as
* replica immediately without waiting for primary and replica to be in sync.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
switchOverAReplicaServerAsForcedIEItWillReplicaAsPrimaryAndOriginalPrimaryAsReplicaImmediatelyWithoutWaitingForPrimaryAndReplicaToBeInSync(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
Server resource = manager.servers()
.getByResourceGroupWithResponse("testResourceGroup", "pgtestsvc4-replica", com.azure.core.util.Context.NONE)
.getValue();
resource.update().withReplica(new Replica().withPromoteMode(ReadReplicaPromoteMode.SWITCHOVER)
.withPromoteOption(ReplicationPromoteOption.FORCED)).apply();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python promote_replica_as_forced_switchover.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_update(
resource_group_name="testResourceGroup",
server_name="pgtestsvc4-replica",
parameters={"properties": {"replica": {"promoteMode": "switchover", "promoteOption": "forced"}}},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsForcedSwitchover.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsForcedSwitchover.json
func ExampleServersClient_BeginUpdate_switchOverAReplicaServerAsForcedIEItWillReplicaAsPrimaryAndOriginalPrimaryAsReplicaImmediatelyWithoutWaitingForPrimaryAndReplicaToBeInSync() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testResourceGroup", "pgtestsvc4-replica", armpostgresqlflexibleservers.ServerForUpdate{
Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{
Replica: &armpostgresqlflexibleservers.Replica{
PromoteMode: to.Ptr(armpostgresqlflexibleservers.ReadReplicaPromoteModeSwitchover),
PromoteOption: to.Ptr(armpostgresqlflexibleservers.ReplicationPromoteOptionForced),
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Server = armpostgresqlflexibleservers.Server{
// Name: to.Ptr("pgtestsvc4-replica"),
// Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4-replica"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "ElasticServer": to.Ptr("1"),
// },
// Properties: &armpostgresqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
// ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumDisabled),
// PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
// },
// AvailabilityZone: to.Ptr("1"),
// Backup: &armpostgresqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](20),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-26T01:16:58.372Z"); return t}()),
// GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled),
// },
// DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
// Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeSystemManaged),
// },
// FullyQualifiedDomainName: to.Ptr("pgtestsvc4-replica.postgres.database.azure.com"),
// HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("2"),
// State: to.Ptr(armpostgresqlflexibleservers.ServerHAStateHealthy),
// },
// MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// MinorVersion: to.Ptr("6"),
// Network: &armpostgresqlflexibleservers.Network{
// DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"),
// PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"),
// PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateDisabled),
// },
// Replica: &armpostgresqlflexibleservers.Replica{
// Capacity: to.Ptr[int32](5),
// Role: to.Ptr(armpostgresqlflexibleservers.ReplicationRolePrimary),
// },
// State: to.Ptr(armpostgresqlflexibleservers.ServerStateReady),
// Storage: &armpostgresqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowEnabled),
// Iops: to.Ptr[int32](5000),
// StorageSizeGB: to.Ptr[int32](1024),
// Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTiersP30),
// },
// Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve),
// },
// SKU: &armpostgresqlflexibleservers.SKU{
// Name: to.Ptr("Standard_D8s_v3"),
// Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
*
* @summary Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsForcedSwitchover.json
*/
async function switchOverAReplicaServerAsForcedIEItWillReplicaAsPrimaryAndOriginalPrimaryAsReplicaImmediatelyWithoutWaitingForPrimaryAndReplicaToBeInSync() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testResourceGroup";
const serverName = "pgtestsvc4-replica";
const parameters = {
replica: { promoteMode: "switchover", promoteOption: "forced" },
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginUpdateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsForcedSwitchover.json
// this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testResourceGroup";
string serverName = "pgtestsvc4-replica";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// invoke the operation
PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch()
{
Replica = new PostgreSqlFlexibleServersReplica()
{
PromoteMode = ReadReplicaPromoteMode.Switchover,
PromoteOption = ReplicationPromoteOption.Forced,
},
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Enabled",
"tier": "P30",
"iops": 5000
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2024-08-01T18:35:22.123456Z"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"replica": {
"role": "Primary",
"capacity": 5
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Switch over a read replica to primary server with planned data synchronization. Meaning that it waits for data in the read replica to be fully synchronized with its source server before it initiates the switching of roles between the read replica and the primary server.
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"properties": {
"replica": {
"promoteMode": "switchover",
"promoteOption": "planned"
}
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.ReadReplicaPromoteMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Replica;
import com.azure.resourcemanager.postgresqlflexibleserver.models.ReplicationPromoteOption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Server;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers Update.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* PromoteReplicaAsPlannedSwitchover.json
*/
/**
* Sample code: SwitchOver a replica server as planned, i.e. it will wait for replication to complete before
* promoting replica as Primary and original primary as replica.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void
switchOverAReplicaServerAsPlannedIEItWillWaitForReplicationToCompleteBeforePromotingReplicaAsPrimaryAndOriginalPrimaryAsReplica(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
Server resource = manager.servers()
.getByResourceGroupWithResponse("testResourceGroup", "pgtestsvc4-replica", com.azure.core.util.Context.NONE)
.getValue();
resource.update().withReplica(new Replica().withPromoteMode(ReadReplicaPromoteMode.SWITCHOVER)
.withPromoteOption(ReplicationPromoteOption.PLANNED)).apply();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python promote_replica_as_planned_switchover.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_update(
resource_group_name="testResourceGroup",
server_name="pgtestsvc4-replica",
parameters={"properties": {"replica": {"promoteMode": "switchover", "promoteOption": "planned"}}},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsPlannedSwitchover.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsPlannedSwitchover.json
func ExampleServersClient_BeginUpdate_switchOverAReplicaServerAsPlannedIEItWillWaitForReplicationToCompleteBeforePromotingReplicaAsPrimaryAndOriginalPrimaryAsReplica() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testResourceGroup", "pgtestsvc4-replica", armpostgresqlflexibleservers.ServerForUpdate{
Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{
Replica: &armpostgresqlflexibleservers.Replica{
PromoteMode: to.Ptr(armpostgresqlflexibleservers.ReadReplicaPromoteModeSwitchover),
PromoteOption: to.Ptr(armpostgresqlflexibleservers.ReplicationPromoteOptionPlanned),
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Server = armpostgresqlflexibleservers.Server{
// Name: to.Ptr("pgtestsvc4-replica"),
// Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4-replica"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "ElasticServer": to.Ptr("1"),
// },
// Properties: &armpostgresqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
// ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumDisabled),
// PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
// },
// AvailabilityZone: to.Ptr("1"),
// Backup: &armpostgresqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](20),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-26T01:16:58.372Z"); return t}()),
// GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled),
// },
// DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
// Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeSystemManaged),
// },
// FullyQualifiedDomainName: to.Ptr("pgtestsvc4-replica.postgres.database.azure.com"),
// HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("2"),
// State: to.Ptr(armpostgresqlflexibleservers.ServerHAStateHealthy),
// },
// MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// MinorVersion: to.Ptr("6"),
// Network: &armpostgresqlflexibleservers.Network{
// DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"),
// PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"),
// PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateDisabled),
// },
// Replica: &armpostgresqlflexibleservers.Replica{
// Capacity: to.Ptr[int32](5),
// Role: to.Ptr(armpostgresqlflexibleservers.ReplicationRolePrimary),
// },
// State: to.Ptr(armpostgresqlflexibleservers.ServerStateReady),
// Storage: &armpostgresqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowEnabled),
// Iops: to.Ptr[int32](5000),
// StorageSizeGB: to.Ptr[int32](1024),
// Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTiersP30),
// },
// Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve),
// },
// SKU: &armpostgresqlflexibleservers.SKU{
// Name: to.Ptr("Standard_D8s_v3"),
// Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
*
* @summary Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsPlannedSwitchover.json
*/
async function switchOverAReplicaServerAsPlannedIEItWillWaitForReplicationToCompleteBeforePromotingReplicaAsPrimaryAndOriginalPrimaryAsReplica() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testResourceGroup";
const serverName = "pgtestsvc4-replica";
const parameters = {
replica: { promoteMode: "switchover", promoteOption: "planned" },
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginUpdateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PromoteReplicaAsPlannedSwitchover.json
// this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testResourceGroup";
string serverName = "pgtestsvc4-replica";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// invoke the operation
PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch()
{
Replica = new PostgreSqlFlexibleServersReplica()
{
PromoteMode = ReadReplicaPromoteMode.Switchover,
PromoteOption = ReplicationPromoteOption.Planned,
},
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Enabled",
"tier": "P30",
"iops": 5000
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2024-08-01T18:35:22.123456Z"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"replica": {
"role": "Primary",
"capacity": 5
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Update an existing flexible server to upgrade the major version of PostgreSQL database engine.
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"properties": {
"createMode": "Update",
"version": "16"
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateModeForUpdate;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Server;
import com.azure.resourcemanager.postgresqlflexibleserver.models.ServerVersion;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers Update.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* ServerUpdateWithMajorVersionUpgrade.json
*/
/**
* Sample code: ServerUpdateWithMajorVersionUpgrade.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void serverUpdateWithMajorVersionUpgrade(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
Server resource = manager.servers()
.getByResourceGroupWithResponse("testrg", "pgtestsvc4", com.azure.core.util.Context.NONE).getValue();
resource.update().withVersion(ServerVersion.ONE_FOUR).withCreateMode(CreateModeForUpdate.UPDATE).apply();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python server_update_with_major_version_upgrade.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_update(
resource_group_name="testrg",
server_name="pgtestsvc4",
parameters={"properties": {"createMode": "Update", "version": "14"}},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdateWithMajorVersionUpgrade.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdateWithMajorVersionUpgrade.json
func ExampleServersClient_BeginUpdate_serverUpdateWithMajorVersionUpgrade() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testrg", "pgtestsvc4", armpostgresqlflexibleservers.ServerForUpdate{
Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate),
Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionFourteen),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Server = armpostgresqlflexibleservers.Server{
// Name: to.Ptr("pgtestsvc4"),
// Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "ElasticServer": to.Ptr("1"),
// },
// Properties: &armpostgresqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
// ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumDisabled),
// PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
// },
// AvailabilityZone: to.Ptr("1"),
// Backup: &armpostgresqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](7),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-26T01:16:58.372Z"); return t}()),
// GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled),
// },
// DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
// Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeSystemManaged),
// },
// FullyQualifiedDomainName: to.Ptr("c7d7483a8ceb.test-private-dns-zone.postgres.database.azure.com"),
// HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("2"),
// State: to.Ptr(armpostgresqlflexibleservers.ServerHAStateHealthy),
// },
// MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// MinorVersion: to.Ptr("6"),
// Network: &armpostgresqlflexibleservers.Network{
// DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"),
// PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"),
// PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateDisabled),
// },
// State: to.Ptr(armpostgresqlflexibleservers.ServerStateReady),
// Storage: &armpostgresqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowEnabled),
// Iops: to.Ptr[int32](2300),
// StorageSizeGB: to.Ptr[int32](512),
// Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTiersP20),
// },
// Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionFourteen),
// },
// SKU: &armpostgresqlflexibleservers.SKU{
// Name: to.Ptr("Standard_D4s_v3"),
// Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
*
* @summary Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdateWithMajorVersionUpgrade.json
*/
async function serverUpdateWithMajorVersionUpgrade() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg";
const serverName = "pgtestsvc4";
const parameters = { createMode: "Update", version: "14" };
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginUpdateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdateWithMajorVersionUpgrade.json
// this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testrg";
string serverName = "pgtestsvc4";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// invoke the operation
PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch()
{
Version = PostgreSqlFlexibleServerVersion.Ver14,
CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"sku": {
"name": "Standard_D4ds_v5",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.exampleprivatednszone.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"storage": {
"storageSizeGB": 512,
"autoGrow": "Enabled",
"tier": "P20",
"iops": 2300
},
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2024-08-01T18:35:22.123456Z"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Update an existing flexible server with custom maintenance window.
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"properties": {
"createMode": "Update",
"maintenanceWindow": {
"customWindow": "Enabled",
"dayOfWeek": 0,
"startHour": 8,
"startMinute": 0
}
}
}
示例响应
{
"sku": {
"name": "Standard_D4ds_v5",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.exampleprivatednszone.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"storage": {
"storageSizeGB": 512,
"autoGrow": "Disabled",
"tier": "P20",
"iops": 2300
},
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2024-08-01T18:35:22.123456Z"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Enabled",
"dayOfWeek": 0,
"startHour": 8,
"startMinute": 0
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Update an existing flexible server with data encryption based on customer managed key.
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"sku": {
"tier": "GeneralPurpose",
"name": "Standard_D8s_v3"
},
"identity": {
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity": {}
},
"type": "UserAssigned"
},
"properties": {
"administratorLoginPassword": "examplenewpassword",
"createMode": "Update",
"dataEncryption": {
"type": "AzureKeyVault",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
"geoBackupKeyURI": "https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity"
},
"backup": {
"backupRetentionDays": 20
}
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.ArmServerKeyType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateModeForUpdate;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DataEncryption;
import com.azure.resourcemanager.postgresqlflexibleserver.models.IdentityType;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Server;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Sku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserAssignedIdentity;
import com.azure.resourcemanager.postgresqlflexibleserver.models.UserIdentity;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers Update.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/
* ServerUpdateWithDataEncryptionEnabled.json
*/
/**
* Sample code: ServerUpdateWithDataEncryptionEnabled.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void serverUpdateWithDataEncryptionEnabled(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
Server resource = manager.servers()
.getByResourceGroupWithResponse("TestGroup", "pgtestsvc4", com.azure.core.util.Context.NONE).getValue();
resource.update().withSku(new Sku().withName("Standard_D8s_v3").withTier(SkuTier.GENERAL_PURPOSE))
.withIdentity(new UserAssignedIdentity().withUserAssignedIdentities(mapOf(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity",
new UserIdentity(),
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity",
new UserIdentity())).withType(IdentityType.USER_ASSIGNED))
.withAdministratorLoginPassword("newpassword").withBackup(new Backup().withBackupRetentionDays(20))
.withDataEncryption(new DataEncryption().withPrimaryKeyUri("fakeTokenPlaceholder")
.withPrimaryUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity")
.withGeoBackupKeyUri("fakeTokenPlaceholder")
.withGeoBackupUserAssignedIdentityId(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity")
.withType(ArmServerKeyType.AZURE_KEY_VAULT))
.withCreateMode(CreateModeForUpdate.UPDATE).apply();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python server_update_with_data_encryption_enabled.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_update(
resource_group_name="TestGroup",
server_name="pgtestsvc4",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity": {},
},
},
"properties": {
"administratorLoginPassword": "newpassword",
"backup": {"backupRetentionDays": 20},
"createMode": "Update",
"dataEncryption": {
"geoBackupKeyURI": "https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity",
"primaryKeyURI": "https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity",
"type": "AzureKeyVault",
},
},
"sku": {"name": "Standard_D8s_v3", "tier": "GeneralPurpose"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdateWithDataEncryptionEnabled.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdateWithDataEncryptionEnabled.json
func ExampleServersClient_BeginUpdate_serverUpdateWithDataEncryptionEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "TestGroup", "pgtestsvc4", armpostgresqlflexibleservers.ServerForUpdate{
Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{
Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity": {},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity": {},
},
},
Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{
AdministratorLoginPassword: to.Ptr("newpassword"),
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](20),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate),
DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeAzureKeyVault),
GeoBackupKeyURI: to.Ptr("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"),
GeoBackupUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity"),
PrimaryKeyURI: to.Ptr("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"),
PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"),
},
},
SKU: &armpostgresqlflexibleservers.SKU{
Name: to.Ptr("Standard_D8s_v3"),
Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Server = armpostgresqlflexibleservers.Server{
// Name: to.Ptr("pgtestsvc4"),
// Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "ElasticServer": to.Ptr("1"),
// },
// Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{
// Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned),
// UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{
// "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity": &armpostgresqlflexibleservers.UserIdentity{
// ClientID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
// PrincipalID: to.Ptr("0a4e0c6e-7751-4078-ae1f-a477306c11e9"),
// },
// "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity": &armpostgresqlflexibleservers.UserIdentity{
// ClientID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
// PrincipalID: to.Ptr("0a4e0c6e-7751-4078-ae1f-a477306c11e9"),
// },
// "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity-1": &armpostgresqlflexibleservers.UserIdentity{
// ClientID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
// PrincipalID: to.Ptr("90008082-e024-4cc3-8fcf-63bcdb9cf6b6"),
// },
// },
// },
// Properties: &armpostgresqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
// ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumDisabled),
// PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
// },
// AvailabilityZone: to.Ptr("1"),
// Backup: &armpostgresqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](20),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-26T01:16:58.372Z"); return t}()),
// GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumEnabled),
// },
// DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
// Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeAzureKeyVault),
// GeoBackupEncryptionKeyStatus: to.Ptr(armpostgresqlflexibleservers.KeyStatusEnumValid),
// GeoBackupKeyURI: to.Ptr("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"),
// GeoBackupUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity"),
// PrimaryEncryptionKeyStatus: to.Ptr(armpostgresqlflexibleservers.KeyStatusEnumValid),
// PrimaryKeyURI: to.Ptr("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"),
// PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"),
// },
// FullyQualifiedDomainName: to.Ptr("c7d7483a8ceb.test-private-dns-zone.postgres.database.azure.com"),
// HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("2"),
// State: to.Ptr(armpostgresqlflexibleservers.ServerHAStateHealthy),
// },
// MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// MinorVersion: to.Ptr("6"),
// Network: &armpostgresqlflexibleservers.Network{
// DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"),
// PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"),
// PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateDisabled),
// },
// State: to.Ptr(armpostgresqlflexibleservers.ServerStateReady),
// Storage: &armpostgresqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowDisabled),
// Iops: to.Ptr[int32](5000),
// StorageSizeGB: to.Ptr[int32](1024),
// Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTiersP30),
// },
// Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve),
// },
// SKU: &armpostgresqlflexibleservers.SKU{
// Name: to.Ptr("Standard_D8s_v3"),
// Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
*
* @summary Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdateWithDataEncryptionEnabled.json
*/
async function serverUpdateWithDataEncryptionEnabled() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup";
const serverName = "pgtestsvc4";
const parameters = {
administratorLoginPassword: "newpassword",
backup: { backupRetentionDays: 20 },
createMode: "Update",
dataEncryption: {
type: "AzureKeyVault",
geoBackupKeyURI:
"https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787",
geoBackupUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity",
primaryKeyURI:
"https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787",
primaryUserAssignedIdentityId:
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity",
},
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/testresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testGeoUsermanagedidentity":
{},
"/subscriptions/ffffffffFfffFfffFfffFfffffffffff/resourceGroups/testresourcegroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testUsermanagedidentity":
{},
},
},
sku: { name: "Standard_D8s_v3", tier: "GeneralPurpose" },
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginUpdateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdateWithDataEncryptionEnabled.json
// this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "TestGroup";
string serverName = "pgtestsvc4";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// invoke the operation
PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch()
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned)
{
UserAssignedIdentities =
{
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity"] = new UserAssignedIdentity(),
["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(),
},
},
AdministratorLoginPassword = "newpassword",
Backup = new PostgreSqlFlexibleServerBackupProperties()
{
BackupRetentionDays = 20,
},
DataEncryption = new PostgreSqlFlexibleServerDataEncryption()
{
PrimaryKeyUri = new Uri("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"),
PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"),
GeoBackupKeyUri = new Uri("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"),
GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity",
KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault,
},
CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"identity": {
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity": {
"principalId": "pppppppp-pppp-pppp-pppp-pppppppppppp",
"clientId": "cccccccc-cccc-cccc-cccc-cccccccccccc"
},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity-1": {
"principalId": "90008082-e024-4cc3-8fcf-63bcdb9cf6b6",
"clientId": "cccccccc-cccc-cccc-cccc-cccccccccccc"
},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity": {
"principalId": "pppppppp-pppp-pppp-pppp-pppppppppppp",
"clientId": "cccccccc-cccc-cccc-cccc-cccccccccccc"
}
},
"type": "UserAssigned",
"tenantId": "cccccccc-cccc-cccc-cccc-cccccccccccc"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.exampleprivatednszone.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"dataEncryption": {
"type": "AzureKeyVault",
"primaryKeyURI": "https://exampleprimarykeyvault.vault.azure.net/keys/examplekey/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleprimaryidentity",
"geoBackupKeyURI": "https://examplegeoredundantkeyvault.vault.azure.net/keys/examplekey/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplegeoredundantidentity",
"primaryEncryptionKeyStatus": "Valid",
"geoBackupEncryptionKeyStatus": "Valid"
},
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Disabled",
"tier": "P30",
"iops": 5000
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Enabled",
"earliestRestoreDate": "2024-08-01T18:35:22.123456Z"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Update an existing flexible server with Microsoft Entra authentication enabled.
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"sku": {
"tier": "GeneralPurpose",
"name": "Standard_D8s_v3"
},
"properties": {
"administratorLoginPassword": "examplenewpassword",
"createMode": "Update",
"authConfig": {
"activeDirectoryAuth": "Enabled",
"passwordAuth": "Enabled",
"tenantId": "tttttt-tttt-tttt-tttt-tttttttttttt"
},
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Disabled",
"tier": "P30"
},
"backup": {
"backupRetentionDays": 20
}
}
}
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.exampleprivatednszone.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Enabled",
"passwordAuth": "Enabled",
"tenantId": "tttttt-tttt-tttt-tttt-tttttttttttt"
},
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Disabled",
"tier": "P30",
"iops": 5000
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2024-08-01T18:35:22.123456Z"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Update an existing flexible server.
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver?api-version=2024-08-01
{
"sku": {
"tier": "GeneralPurpose",
"name": "Standard_D8s_v3"
},
"properties": {
"administratorLoginPassword": "examplenewpassword",
"createMode": "Update",
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Enabled",
"tier": "P30"
},
"backup": {
"backupRetentionDays": 20
}
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.AzureManagedDiskPerformanceTiers;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateModeForUpdate;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Server;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Sku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Storage;
import com.azure.resourcemanager.postgresqlflexibleserver.models.StorageAutoGrow;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Servers Update.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdate.json
*/
/**
* Sample code: ServerUpdate.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void serverUpdate(com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
Server resource = manager.servers()
.getByResourceGroupWithResponse("TestGroup", "pgtestsvc4", com.azure.core.util.Context.NONE).getValue();
resource.update().withSku(new Sku().withName("Standard_D8s_v3").withTier(SkuTier.GENERAL_PURPOSE))
.withAdministratorLoginPassword("newpassword")
.withStorage(new Storage().withStorageSizeGB(1024).withAutoGrow(StorageAutoGrow.ENABLED)
.withTier(AzureManagedDiskPerformanceTiers.P30))
.withBackup(new Backup().withBackupRetentionDays(20)).withCreateMode(CreateModeForUpdate.UPDATE).apply();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python server_update.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_update(
resource_group_name="TestGroup",
server_name="pgtestsvc4",
parameters={
"properties": {
"administratorLoginPassword": "newpassword",
"backup": {"backupRetentionDays": 20},
"createMode": "Update",
"storage": {"autoGrow": "Enabled", "storageSizeGB": 1024, "tier": "P30"},
},
"sku": {"name": "Standard_D8s_v3", "tier": "GeneralPurpose"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpostgresqlflexibleservers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ecee919199a39cc0d864410f540aa105bf7cdb64/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdate.json
func ExampleServersClient_BeginUpdate_serverUpdate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "TestGroup", "pgtestsvc4", armpostgresqlflexibleservers.ServerForUpdate{
Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{
AdministratorLoginPassword: to.Ptr("newpassword"),
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](20),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate),
Storage: &armpostgresqlflexibleservers.Storage{
AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowEnabled),
StorageSizeGB: to.Ptr[int32](1024),
Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTiersP30),
},
},
SKU: &armpostgresqlflexibleservers.SKU{
Name: to.Ptr("Standard_D8s_v3"),
Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Server = armpostgresqlflexibleservers.Server{
// Name: to.Ptr("pgtestsvc4"),
// Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "ElasticServer": to.Ptr("1"),
// },
// Properties: &armpostgresqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
// ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumDisabled),
// PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
// },
// AvailabilityZone: to.Ptr("1"),
// Backup: &armpostgresqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](20),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-26T01:16:58.372Z"); return t}()),
// GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled),
// },
// DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
// Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeSystemManaged),
// },
// FullyQualifiedDomainName: to.Ptr("c7d7483a8ceb.test-private-dns-zone.postgres.database.azure.com"),
// HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("2"),
// State: to.Ptr(armpostgresqlflexibleservers.ServerHAStateHealthy),
// },
// MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// MinorVersion: to.Ptr("6"),
// Network: &armpostgresqlflexibleservers.Network{
// DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"),
// PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"),
// PublicNetworkAccess: to.Ptr(armpostgresqlflexibleservers.ServerPublicNetworkAccessStateDisabled),
// },
// State: to.Ptr(armpostgresqlflexibleservers.ServerStateReady),
// Storage: &armpostgresqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armpostgresqlflexibleservers.StorageAutoGrowEnabled),
// Iops: to.Ptr[int32](5000),
// StorageSizeGB: to.Ptr[int32](1024),
// Tier: to.Ptr(armpostgresqlflexibleservers.AzureManagedDiskPerformanceTiersP30),
// },
// Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve),
// },
// SKU: &armpostgresqlflexibleservers.SKU{
// Name: to.Ptr("Standard_D8s_v3"),
// Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
*
* @summary Updates an existing server. The request body can contain one to many of the properties present in the normal server definition.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdate.json
*/
async function serverUpdate() {
const subscriptionId =
process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup";
const serverName = "pgtestsvc4";
const parameters = {
administratorLoginPassword: "newpassword",
backup: { backupRetentionDays: 20 },
createMode: "Update",
sku: { name: "Standard_D8s_v3", tier: "GeneralPurpose" },
storage: { autoGrow: "Enabled", storageSizeGB: 1024, tier: "P30" },
};
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId);
const result = await client.servers.beginUpdateAndWait(resourceGroupName, serverName, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
// Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerUpdate.json
// this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this PostgreSqlFlexibleServerResource created on azure
// for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "TestGroup";
string serverName = "pgtestsvc4";
ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId);
// invoke the operation
PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch()
{
Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose),
AdministratorLoginPassword = "newpassword",
Storage = new PostgreSqlFlexibleServerStorage()
{
StorageSizeInGB = 1024,
AutoGrow = StorageAutoGrow.Enabled,
Tier = PostgreSqlManagedDiskPerformanceTier.P30,
},
Backup = new PostgreSqlFlexibleServerBackupProperties()
{
BackupRetentionDays = 20,
},
CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update,
};
ArmOperation<PostgreSqlFlexibleServerResource> lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch);
PostgreSqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PostgreSqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "exampleserver.exampleprivatednszone.postgres.database.azure.com",
"version": "16",
"minorVersion": "8",
"administratorLogin": "administratorlogin",
"state": "Ready",
"availabilityZone": "1",
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"storage": {
"storageSizeGB": 1024,
"autoGrow": "Enabled",
"tier": "P30",
"iops": 5000
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2024-08-01T18:30:22.123456Z"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/virtualNetworks/examplevirtualnetwork/subnets/examplesubnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.Network/privateDnsZones/exampleprivatednszone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
}
},
"___location": "westus",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver",
"name": "exampleserver",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/azureAsyncOperation/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
Location: https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DBforPostgreSQL/locations/southeastasia/operationResults/e276a03a-1770-4549-86f5-0edffae8997c?api-version=2024-08-01
定义
activeDirectoryAuthEnum
枚举
指示服务器是否支持 Microsoft Entra 身份验证。
ArmServerKeyType
枚举
灵活服务器使用的数据加密类型。
值 |
说明 |
AzureKeyVault
|
|
SystemManaged
|
|
AuthConfig
Object
灵活服务器的身份验证配置属性。
枚举
灵活服务器的存储层。
值 |
说明 |
P1
|
|
P10
|
|
P15
|
|
P2
|
|
P20
|
|
P3
|
|
P30
|
|
P4
|
|
P40
|
|
P50
|
|
P6
|
|
P60
|
|
P70
|
|
P80
|
|
Backup
Object
灵活服务器的备份属性。
名称 |
类型 |
默认值 |
说明 |
backupRetentionDays
|
integer
(int32)
|
7
|
灵活服务器的备份保留天数。
|
earliestRestoreDate
|
string
(date-time)
|
|
灵活服务器的最早还原点时间 (ISO8601 格式)。
|
geoRedundantBackup
|
GeoRedundantBackupEnum
|
Disabled
|
指示是否将 服务器配置为创建地理位置冗余的备份。
|
createdByType
枚举
创建资源的标识的类型。
值 |
说明 |
Application
|
|
Key
|
|
ManagedIdentity
|
|
User
|
|
CreateMode
枚举
新灵活服务器的创建模式。
值 |
说明 |
Create
|
|
Default
|
|
GeoRestore
|
|
PointInTimeRestore
|
|
Replica
|
|
ReviveDropped
|
|
Update
|
|
CreateModeForUpdate
枚举
现有灵活服务器的更新模式。
DataEncryption
Object
灵活服务器的数据加密属性。
名称 |
类型 |
说明 |
geoBackupEncryptionKeyStatus
|
keyStatusEnum
|
配置了基于客户管理的密钥的数据加密的灵活服务器使用的密钥状态,用于在服务器配置为支持地理冗余备份时加密与服务器关联的地理冗余存储。
|
geoBackupKeyURI
|
string
|
用户分配的托管标识的标识符,用于访问 Azure Key Vault 中的密钥,以便对与配置为支持地理冗余备份的灵活服务器关联的地理冗余存储进行数据加密。
|
geoBackupUserAssignedIdentityId
|
string
|
用户分配的托管标识的标识符,用于访问 Azure Key Vault 中的密钥,以便对与配置为支持地理冗余备份的灵活服务器关联的地理冗余存储进行数据加密。
|
primaryEncryptionKeyStatus
|
keyStatusEnum
|
配置了基于客户管理的密钥的数据加密的灵活服务器使用的密钥状态,用于加密与服务器关联的主存储。
|
primaryKeyURI
|
string
|
Azure Key Vault 中密钥的 URI,用于对与灵活服务器关联的主存储进行数据加密。
|
primaryUserAssignedIdentityId
|
string
|
用户分配的托管标识的标识符,用于访问 Azure Key Vault 中的密钥,以便对与灵活服务器关联的主存储进行数据加密。
|
type
|
ArmServerKeyType
|
灵活服务器使用的数据加密类型。
|
ErrorAdditionalInfo
Object
资源管理错误附加信息。
名称 |
类型 |
说明 |
info
|
object
|
其他信息。
|
type
|
string
|
其他信息类型。
|
ErrorDetail
Object
错误详细信息。
ErrorResponse
Object
错误响应
GeoRedundantBackupEnum
枚举
指示是否将 服务器配置为创建地理位置冗余的备份。
HighAvailability
Object
灵活服务器的高可用性属性。
名称 |
类型 |
默认值 |
说明 |
mode
|
HighAvailabilityMode
|
Disabled
|
灵活服务器的高可用性模式。
|
standbyAvailabilityZone
|
string
|
|
与高可用性设置为 SameZone 或 ZoneRedundant 时创建的备用服务器关联的可用区。
|
state
|
ServerHAState
|
|
当高可用性设置为 SameZone 或 ZoneRedundant 时创建的备用服务器的可能状态。
|
HighAvailabilityMode
枚举
灵活服务器的高可用性模式。
值 |
说明 |
Disabled
|
|
SameZone
|
|
ZoneRedundant
|
|
IdentityType
枚举
与灵活服务器关联的身份类型。
值 |
说明 |
None
|
|
SystemAssigned
|
|
SystemAssigned,UserAssigned
|
|
UserAssigned
|
|
keyStatusEnum
枚举
配置了基于客户管理的密钥的数据加密的灵活服务器使用的密钥状态,用于加密与服务器关联的主存储。
MaintenanceWindow
Object
灵活服务器的维护时段属性。
名称 |
类型 |
默认值 |
说明 |
customWindow
|
string
|
Disabled
|
指示自定义窗口是启用还是禁用。
|
dayOfWeek
|
integer
(int32)
|
0
|
用于维护时段的星期几。
|
startHour
|
integer
(int32)
|
0
|
用于维护时段的开始时间。
|
startMinute
|
integer
(int32)
|
0
|
用于维护时段的开始分钟。
|
Network
Object
灵活服务器的网络属性。 仅当您希望将服务器集成到客户提供的虚拟网络中时,才需要。
名称 |
类型 |
说明 |
delegatedSubnetResourceId
|
string
|
委托子网的资源标识符。 在创建新服务器期间是必需的,以防您希望将服务器集成到您自己的虚拟网络中。 对于更新作,如果要更改为私有 DNS 区域分配的值,则只需提供此属性。
|
privateDnsZoneArmResourceId
|
string
|
私有 DNS 区域的标识符。 在创建新服务器期间是必需的,以防您希望将服务器集成到您自己的虚拟网络中。 对于更新作,如果要更改为私有 DNS 区域分配的值,则只需提供此属性。
|
publicNetworkAccess
|
ServerPublicNetworkAccessState
|
指示是否启用公共网络访问。
|
passwordAuthEnum
枚举
指示服务器是否支持基于密码的身份验证。
PrivateEndpoint
Object
专用终结点资源。
名称 |
类型 |
说明 |
id
|
string
|
专用终结点的 ARM 标识符。
|
PrivateEndpointConnection
Object
与指定灵活服务器关联的专用终结点连接列表。
名称 |
类型 |
说明 |
id
|
string
(arm-id)
|
资源的完全限定资源 ID。 例如“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”
|
name
|
string
|
资源的名称
|
properties.groupIds
|
string[]
|
专用终结点资源的组 ID。
|
properties.privateEndpoint
|
PrivateEndpoint
|
专用终结点资源。
|
properties.privateLinkServiceConnectionState
|
PrivateLinkServiceConnectionState
|
有关服务使用者与提供程序之间的连接状态的信息集合。
|
properties.provisioningState
|
PrivateEndpointConnectionProvisioningState
|
专用终结点连接资源的预配状态。
|
systemData
|
systemData
|
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
PrivateEndpointConnectionProvisioningState
枚举
专用终结点连接资源的预配状态。
值 |
说明 |
Creating
|
|
Deleting
|
|
Failed
|
|
Succeeded
|
|
PrivateEndpointServiceConnectionStatus
枚举
指示连接是否已被服务的所有者批准/拒绝/删除。
值 |
说明 |
Approved
|
|
Pending
|
|
Rejected
|
|
PrivateLinkServiceConnectionState
Object
有关服务使用者与提供程序之间的连接状态的信息集合。
枚举
要应用于只读副本的作类型。 此属性是 write only。 Standalone 意味着只读副本将被提升为独立服务器,并将成为完全独立于复制集的实体。 切换意味着只读副本将与主服务器一起扮演角色。
值 |
说明 |
standalone
|
|
switchover
|
|
Replica
Object
灵活服务器的只读副本属性。 仅在您想要升级服务器时才需要。
名称 |
类型 |
说明 |
capacity
|
integer
(int32)
|
灵活服务器允许的最大只读副本数。
|
promoteMode
|
ReadReplicaPromoteMode
|
要应用于只读副本的作类型。 此属性是 write only。 Standalone 意味着只读副本将被提升为独立服务器,并将成为完全独立于复制集的实体。 切换意味着只读副本将与主服务器一起扮演角色。
|
promoteOption
|
ReplicationPromoteOption
|
处理 promoteMode 属性中指定的作时使用的数据同步选项 此属性为“只写”。 Planned 表示作将等待只读副本中的数据与其源服务器完全同步,然后再启动作。 Forced 表示作在启动作之前不会等待只读副本中的数据与其源服务器同步。
|
replicationState
|
ReplicationState
|
指示只读副本的复制状态。 仅当目标灵活服务器是只读副本时,才会返回此属性。 可能的值包括 Active、Broken、Catchup、Provisioning、Reconfiguring 和 Updating
|
role
|
ReplicationRole
|
服务器在复制集中的角色。
|
枚举
处理 promoteMode 属性中指定的作时使用的数据同步选项 此属性为“只写”。 Planned 表示作将等待只读副本中的数据与其源服务器完全同步,然后再启动作。 Forced 表示作在启动作之前不会等待只读副本中的数据与其源服务器同步。
ReplicationRole
枚举
服务器在复制集中的角色。
值 |
说明 |
AsyncReplica
|
|
GeoAsyncReplica
|
|
None
|
|
Primary
|
|
ReplicationState
枚举
指示只读副本的复制状态。 仅当目标灵活服务器是只读副本时,才会返回此属性。 可能的值包括 Active、Broken、Catchup、Provisioning、Reconfiguring 和 Updating
值 |
说明 |
Active
|
|
Broken
|
|
Catchup
|
|
Provisioning
|
|
Reconfiguring
|
|
Updating
|
|
Server
Object
灵活服务器。
名称 |
类型 |
说明 |
id
|
string
(arm-id)
|
资源的完全限定资源 ID。 例如“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”
|
identity
|
UserAssignedIdentity
|
用户分配的托管标识分配给灵活服务器。
|
___location
|
string
|
资源所在的地理位置
|
name
|
string
|
资源的名称
|
properties.administratorLogin
|
string
|
指定为分配给 PostgreSQL 实例的第一个基于密码的管理员的登录名。 首次在服务器上启用基于密码的身份验证时,必须指定此参数。 一旦设置为给定值,则在服务器的其余生命周期内无法更改。 如果在启用了基于密码的身份验证的服务器上禁用基于密码的身份验证,则不会删除此基于密码的角色。
|
properties.administratorLoginPassword
|
string
(password)
|
分配给管理员登录名的密码。 只要启用了密码身份验证,就可以随时更改此密码。
|
properties.authConfig
|
AuthConfig
|
灵活服务器的身份验证配置属性。
|
properties.availabilityZone
|
string
|
灵活服务器的可用性区域。
|
properties.backup
|
Backup
|
灵活服务器的备份属性。
|
properties.createMode
|
CreateMode
|
新灵活服务器的创建模式。
|
properties.dataEncryption
|
DataEncryption
|
灵活服务器的数据加密属性。
|
properties.fullyQualifiedDomainName
|
string
|
灵活服务器的完全限定域名。
|
properties.highAvailability
|
HighAvailability
|
灵活服务器的高可用性属性。
|
properties.maintenanceWindow
|
MaintenanceWindow
|
灵活服务器的维护时段属性。
|
properties.minorVersion
|
string
|
PostgreSQL 数据库引擎的次要版本。
|
properties.network
|
Network
|
灵活服务器的网络属性。 仅当您希望将服务器集成到客户提供的虚拟网络中时,才需要。
|
properties.pointInTimeUTC
|
string
(date-time)
|
要在新灵活服务器中还原的备份的创建时间(ISO8601格式)。 当 'createMode' 为 'PointInTimeRestore'、'GeoRestore' 或 'ReviveDropped' 时,它是必需的。
|
properties.privateEndpointConnections
|
PrivateEndpointConnection[]
|
与指定灵活服务器关联的专用终结点连接列表。
|
properties.replica
|
Replica
|
灵活服务器的只读副本属性。 仅在您想要升级服务器时才需要。
|
properties.replicaCapacity
|
integer
(int32)
|
灵活服务器允许的最大只读副本数。
|
properties.replicationRole
|
ReplicationRole
|
服务器在复制集中的角色。
|
properties.sourceServerResourceId
|
string
|
要用作新灵活服务器源的灵活服务器的标识符。 当 'createMode' 为 'PointInTimeRestore'、'GeoRestore'、'Replica' 或 'ReviveDropped' 时是必需的。 仅当目标灵活服务器是只读副本时,才会返回此属性。
|
properties.state
|
ServerState
|
灵活服务器的可能状态。
|
properties.storage
|
Storage
|
灵活服务器的存储属性。
|
properties.version
|
ServerVersion
|
PostgreSQL 数据库引擎的主要版本。
|
sku
|
Sku
|
灵活服务器的计算层和大小。
|
systemData
|
systemData
|
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
|
tags
|
object
|
资源标记。
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
ServerForUpdate
Object
更新灵活服务器所需的参数。
名称 |
类型 |
说明 |
identity
|
UserAssignedIdentity
|
描述应用程序的标识。
|
properties.administratorLogin
|
string
|
指定为分配给 PostgreSQL 实例的第一个基于密码的管理员的登录名。 首次在服务器上启用基于密码的身份验证时,必须指定此参数。 一旦设置为给定值,则在服务器的其余生命周期内无法更改。 如果在启用了基于密码的身份验证的服务器上禁用基于密码的身份验证,则不会删除此基于密码的角色。
|
properties.administratorLoginPassword
|
string
(password)
|
分配给管理员登录名的密码。 只要启用了密码身份验证,就可以随时更改此密码。
|
properties.authConfig
|
AuthConfig
|
灵活服务器的身份验证配置属性。
|
properties.backup
|
Backup
|
灵活服务器的备份属性。
|
properties.createMode
|
CreateModeForUpdate
|
现有灵活服务器的更新模式。
|
properties.dataEncryption
|
DataEncryption
|
灵活服务器的数据加密属性。
|
properties.highAvailability
|
HighAvailability
|
灵活服务器的高可用性属性。
|
properties.maintenanceWindow
|
MaintenanceWindow
|
灵活服务器的维护时段属性。
|
properties.network
|
Network
|
灵活服务器的网络属性。 仅当您希望将服务器集成到客户提供的虚拟网络中时,才需要。
|
properties.replica
|
Replica
|
灵活服务器的只读副本属性。 仅在您想要升级服务器时才需要。
|
properties.replicationRole
|
ReplicationRole
|
服务器在复制集中的角色。
|
properties.storage
|
Storage
|
灵活服务器的存储属性。
|
properties.version
|
ServerVersion
|
PostgreSQL 数据库引擎的主要版本。
|
sku
|
Sku
|
灵活服务器的计算层和大小。
|
tags
|
object
|
键值对形式的特定于应用程序的元数据。
|
ServerHAState
枚举
当高可用性设置为 SameZone 或 ZoneRedundant 时创建的备用服务器的可能状态。
值 |
说明 |
CreatingStandby
|
|
FailingOver
|
|
Healthy
|
|
NotEnabled
|
|
RemovingStandby
|
|
ReplicatingData
|
|
ServerPublicNetworkAccessState
枚举
指示是否启用公共网络访问。
ServerState
枚举
灵活服务器的可能状态。
值 |
说明 |
Disabled
|
|
Dropping
|
|
Ready
|
|
Starting
|
|
Stopped
|
|
Stopping
|
|
Updating
|
|
ServerVersion
枚举
PostgreSQL 数据库引擎的主要版本。
Sku
Object
灵活服务器的计算层和大小。
名称 |
类型 |
说明 |
name
|
string
|
名称 ,用于已知分配给灵活服务器的给定计算大小。
|
tier
|
SkuTier
|
分配给灵活服务器的计算层。
|
SkuTier
枚举
分配给灵活服务器的计算层。
值 |
说明 |
Burstable
|
|
GeneralPurpose
|
|
MemoryOptimized
|
|
Storage
Object
灵活服务器的存储属性。
名称 |
类型 |
说明 |
autoGrow
|
StorageAutoGrow
|
当可用空间接近零且条件允许自动增加存储大小时,启用或禁用灵活服务器的存储大小的自动增长的标志。
|
iops
|
integer
(int32)
|
存储支持的最大 IOPS。 当存储类型为 PremiumV2_LRS 时是必需的。
|
storageSizeGB
|
integer
(int32)
|
分配给灵活服务器的存储大小。
|
throughput
|
integer
(int32)
|
存储支持的最大吞吐量。 当存储类型为 PremiumV2_LRS 时是必需的。
|
tier
|
AzureManagedDiskPerformanceTiers
|
灵活服务器的存储层。
|
type
|
StorageType
|
分配给灵活服务器的存储类型。 允许的值为 Premium_LRS 或 PremiumV2_LRS。 如果未指定,则默认为 Premium_LRS。
|
StorageAutoGrow
枚举
当可用空间接近零且条件允许自动增加存储大小时,启用或禁用灵活服务器的存储大小的自动增长的标志。
StorageType
枚举
分配给灵活服务器的存储类型。 允许的值为 Premium_LRS 或 PremiumV2_LRS。 如果未指定,则默认为 Premium_LRS。
值 |
说明 |
PremiumV2_LRS
|
|
Premium_LRS
|
|
systemData
Object
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
名称 |
类型 |
说明 |
createdAt
|
string
(date-time)
|
资源创建时间戳(UTC)。
|
createdBy
|
string
|
创建资源的标识。
|
createdByType
|
createdByType
|
创建资源的标识的类型。
|
lastModifiedAt
|
string
(date-time)
|
上次修改的资源时间戳(UTC)
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识的类型。
|
UserAssignedIdentity
Object
用户分配的托管标识分配给灵活服务器。
名称 |
类型 |
说明 |
principalId
|
string
|
与用户分配的托管标识关联的服务主体的对象的标识符。
|
tenantId
|
string
|
灵活服务器租户的标识符。
|
type
|
IdentityType
|
与灵活服务器关联的身份类型。
|
userAssignedIdentities
|
<string,
UserIdentity>
|
用户分配的托管标识的映射。
|
UserIdentity
Object
用户分配的与灵活服务器关联的托管标识。
名称 |
类型 |
说明 |
clientId
|
string
|
与用户分配的托管标识关联的服务主体的客户端的标识符。
|
principalId
|
string
|
与用户分配的托管标识关联的服务主体的对象的标识符。
|