更新现有服务器。 请求正文可以包含正常服务器定义中存在的一到多个属性。
PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}?api-version=2022-12-01
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
resourceGroupName
|
path |
True
|
string
|
资源组的名称。 此名称不区分大小写。
|
serverName
|
path |
True
|
string
|
服务器的名称。
正则表达式模式: ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*
|
subscriptionId
|
path |
True
|
string
|
目标订阅的 ID。
|
api-version
|
query |
True
|
string
|
要用于此操作的 API 版本。
|
请求正文
响应
名称 |
类型 |
说明 |
200 OK
|
Server
|
确定
|
202 Accepted
|
|
已接受
标头
Location: string
|
Other Status Codes
|
ErrorResponse
|
描述操作失败原因的错误响应。
|
安全性
azure_auth
Azure Active Directory OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
ServerUpdate
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4?api-version=2022-12-01
{
"sku": {
"tier": "GeneralPurpose",
"name": "Standard_D8s_v3"
},
"properties": {
"administratorLoginPassword": "newpassword",
"createMode": "Update",
"storage": {
"storageSizeGB": 1024
},
"backup": {
"backupRetentionDays": 20
}
}
}
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 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/2022-12-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))
.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
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/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/75ece9197dbac70ac0ba651c53a79c1841944be2/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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{
StorageSizeGB: to.Ptr[int32](1024),
},
},
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{
// StorageSizeGB: to.Ptr[int32](1024),
// },
// 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");
/**
* 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/2022-12-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: { storageSizeGB: 1024 },
};
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
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "c7d7483a8ceb.test-private-dns-zone.postgres.database.azure.com",
"version": "12",
"minorVersion": "6",
"administratorLogin": "cloudsa",
"state": "Ready",
"availabilityZone": "1",
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"storage": {
"storageSizeGB": 1024
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2021-05-26T01:16:58.3723361+00:00"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
}
},
"location": "westus",
"tags": {
"ElasticServer": "1"
},
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4",
"name": "pgtestsvc4",
"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=2022-12-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=2022-12-01
ServerUpdateWithAadAuthEnabled
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4?api-version=2022-12-01
{
"sku": {
"tier": "GeneralPurpose",
"name": "Standard_D8s_v3"
},
"properties": {
"administratorLoginPassword": "newpassword",
"createMode": "Update",
"authConfig": {
"activeDirectoryAuth": "Enabled",
"passwordAuth": "Enabled",
"tenantId": "tttttt-tttt-tttt-tttt-tttttttttttt"
},
"storage": {
"storageSizeGB": 1024
},
"backup": {
"backupRetentionDays": 20
}
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.ActiveDirectoryAuthEnum;
import com.azure.resourcemanager.postgresqlflexibleserver.models.AuthConfig;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Backup;
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateModeForUpdate;
import com.azure.resourcemanager.postgresqlflexibleserver.models.PasswordAuthEnum;
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 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/2022-12-01/examples/ServerUpdateWithAadAuthEnabled.json
*/
/**
* Sample code: ServerUpdateWithAadAuthEnabled.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void serverUpdateWithAadAuthEnabled(
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))
.withBackup(new Backup().withBackupRetentionDays(20))
.withAuthConfig(
new AuthConfig()
.withActiveDirectoryAuth(ActiveDirectoryAuthEnum.ENABLED)
.withPasswordAuth(PasswordAuthEnum.ENABLED)
.withTenantId("tttttt-tttt-tttt-tttt-tttttttttttt"))
.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
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/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/75ece9197dbac70ac0ba651c53a79c1841944be2/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithAadAuthEnabled.json
func ExampleServersClient_BeginUpdate_serverUpdateWithAadAuthEnabled() {
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"),
AuthConfig: &armpostgresqlflexibleservers.AuthConfig{
ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumEnabled),
PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
TenantID: to.Ptr("tttttt-tttt-tttt-tttt-tttttttttttt"),
},
Backup: &armpostgresqlflexibleservers.Backup{
BackupRetentionDays: to.Ptr[int32](20),
},
CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate),
Storage: &armpostgresqlflexibleservers.Storage{
StorageSizeGB: to.Ptr[int32](1024),
},
},
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.ActiveDirectoryAuthEnumEnabled),
// PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled),
// TenantID: to.Ptr("tttttt-tttt-tttt-tttt-tttttttttttt"),
// },
// 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{
// StorageSizeGB: to.Ptr[int32](1024),
// },
// 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");
/**
* 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/2022-12-01/examples/ServerUpdateWithAadAuthEnabled.json
*/
async function serverUpdateWithAadAuthEnabled() {
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",
authConfig: {
activeDirectoryAuth: "Enabled",
passwordAuth: "Enabled",
tenantId: "tttttt-tttt-tttt-tttt-tttttttttttt",
},
backup: { backupRetentionDays: 20 },
createMode: "Update",
sku: { name: "Standard_D8s_v3", tier: "GeneralPurpose" },
storage: { storageSizeGB: 1024 },
};
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
from azure.identity import DefaultAzureCredential
from azure.mgmt.rdbms import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-rdbms
# USAGE
python server_update_with_aad_auth_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={
"properties": {
"administratorLoginPassword": "newpassword",
"authConfig": {
"activeDirectoryAuth": "Enabled",
"passwordAuth": "Enabled",
"tenantId": "tttttt-tttt-tttt-tttt-tttttttttttt",
},
"backup": {"backupRetentionDays": 20},
"createMode": "Update",
"storage": {"storageSizeGB": 1024},
},
"sku": {"name": "Standard_D8s_v3", "tier": "GeneralPurpose"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithAadAuthEnabled.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
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "c7d7483a8ceb.test-private-dns-zone.postgres.database.azure.com",
"version": "12",
"minorVersion": "6",
"administratorLogin": "cloudsa",
"state": "Ready",
"availabilityZone": "1",
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Enabled",
"passwordAuth": "Enabled",
"tenantId": "tttttt-tttt-tttt-tttt-tttttttttttt"
},
"storage": {
"storageSizeGB": 1024
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2021-05-26T01:16:58.3723361+00:00"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
}
},
"location": "westus",
"tags": {
"ElasticServer": "1"
},
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4",
"name": "pgtestsvc4",
"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=2022-12-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=2022-12-01
ServerUpdateWithCustomerMaintenanceWindow
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4?api-version=2022-12-01
{
"properties": {
"createMode": "Update",
"maintenanceWindow": {
"customWindow": "Enabled",
"dayOfWeek": 0,
"startHour": 8,
"startMinute": 0
}
}
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.CreateModeForUpdate;
import com.azure.resourcemanager.postgresqlflexibleserver.models.MaintenanceWindow;
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/2022-12-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json
*/
/**
* Sample code: ServerUpdateWithCustomerMaintenanceWindow.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void serverUpdateWithCustomerMaintenanceWindow(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
Server resource =
manager
.servers()
.getByResourceGroupWithResponse("testrg", "pgtestsvc4", com.azure.core.util.Context.NONE)
.getValue();
resource
.update()
.withMaintenanceWindow(
new MaintenanceWindow()
.withCustomWindow("Enabled")
.withStartHour(8)
.withStartMinute(0)
.withDayOfWeek(0))
.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
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/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/75ece9197dbac70ac0ba651c53a79c1841944be2/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json
func ExampleServersClient_BeginUpdate_serverUpdateWithCustomerMaintenanceWindow() {
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),
MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{
CustomWindow: to.Ptr("Enabled"),
DayOfWeek: to.Ptr[int32](0),
StartHour: to.Ptr[int32](8),
StartMinute: to.Ptr[int32](0),
},
},
}, 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("Enabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](8),
// 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{
// StorageSizeGB: to.Ptr[int32](512),
// },
// Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve),
// },
// 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");
/**
* 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/2022-12-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json
*/
async function serverUpdateWithCustomerMaintenanceWindow() {
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",
maintenanceWindow: {
customWindow: "Enabled",
dayOfWeek: 0,
startHour: 8,
startMinute: 0,
},
};
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
from azure.identity import DefaultAzureCredential
from azure.mgmt.rdbms import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-rdbms
# USAGE
python server_update_with_customer_maintenance_window.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",
"maintenanceWindow": {"customWindow": "Enabled", "dayOfWeek": 0, "startHour": 8, "startMinute": 0},
}
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithCustomerMaintenanceWindow.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
示例响应
{
"sku": {
"name": "Standard_D4s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "c7d7483a8ceb.test-private-dns-zone.postgres.database.azure.com",
"version": "12",
"minorVersion": "6",
"administratorLogin": "cloudsa",
"state": "Ready",
"availabilityZone": "1",
"storage": {
"storageSizeGB": 512
},
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2021-05-26T01:16:58.3723361+00:00"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Enabled",
"dayOfWeek": 0,
"startHour": 8,
"startMinute": 0
}
},
"location": "westus",
"tags": {
"ElasticServer": "1"
},
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4",
"name": "pgtestsvc4",
"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=2022-12-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=2022-12-01
ServerUpdateWithDataEncryptionEnabled
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4?api-version=2022-12-01
{
"sku": {
"tier": "GeneralPurpose",
"name": "Standard_D8s_v3"
},
"identity": {
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity": {}
},
"type": "UserAssigned"
},
"properties": {
"administratorLoginPassword": "newpassword",
"createMode": "Update",
"dataEncryption": {
"type": "AzureKeyVault",
"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"
},
"storage": {
"storageSizeGB": 1024
},
"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.Storage;
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/2022-12-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-usermanagedidentity",
new UserIdentity()))
.withType(IdentityType.USER_ASSIGNED))
.withAdministratorLoginPassword("newpassword")
.withStorage(new Storage().withStorageSizeGB(1024))
.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")
.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
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/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/75ece9197dbac70ac0ba651c53a79c1841944be2/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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-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),
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"),
},
Storage: &armpostgresqlflexibleservers.Storage{
StorageSizeGB: to.Ptr[int32](1024),
},
},
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-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.GeoRedundantBackupEnumDisabled),
// },
// DataEncryption: &armpostgresqlflexibleservers.DataEncryption{
// Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeAzureKeyVault),
// 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{
// StorageSizeGB: to.Ptr[int32](1024),
// },
// 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");
/**
* 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/2022-12-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",
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/testUsermanagedidentity":
{},
},
},
sku: { name: "Standard_D8s_v3", tier: "GeneralPurpose" },
storage: { storageSizeGB: 1024 },
};
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
from azure.identity import DefaultAzureCredential
from azure.mgmt.rdbms import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-rdbms
# 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-usermanagedidentity": {}
},
},
"properties": {
"administratorLoginPassword": "newpassword",
"backup": {"backupRetentionDays": 20},
"createMode": "Update",
"dataEncryption": {
"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",
},
"storage": {"storageSizeGB": 1024},
},
"sku": {"name": "Standard_D8s_v3", "tier": "GeneralPurpose"},
},
).result()
print(response)
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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
示例响应
{
"sku": {
"name": "Standard_D8s_v3",
"tier": "GeneralPurpose"
},
"identity": {
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity": {
"principalId": "0a4e0c6e-7751-4078-ae1f-a477306c11e9",
"clientId": "72f988bf-86f1-41af-91ab-2d7cd011db47"
},
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity-1": {
"principalId": "90008082-e024-4cc3-8fcf-63bcdb9cf6b6",
"clientId": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
},
"type": "UserAssigned"
},
"properties": {
"fullyQualifiedDomainName": "c7d7483a8ceb.test-private-dns-zone.postgres.database.azure.com",
"version": "12",
"minorVersion": "6",
"administratorLogin": "cloudsa",
"state": "Ready",
"availabilityZone": "1",
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"dataEncryption": {
"type": "AzureKeyVault",
"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"
},
"storage": {
"storageSizeGB": 1024
},
"backup": {
"backupRetentionDays": 20,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2021-05-26T01:16:58.3723361+00:00"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
}
},
"location": "westus",
"tags": {
"ElasticServer": "1"
},
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4",
"name": "pgtestsvc4",
"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=2022-12-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=2022-12-01
ServerUpdateWithMajorVersionUpgrade
示例请求
PATCH https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4?api-version=2022-12-01
{
"properties": {
"createMode": "Update",
"version": "14"
}
}
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/2022-12-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
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/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/75ece9197dbac70ac0ba651c53a79c1841944be2/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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{
// StorageSizeGB: to.Ptr[int32](512),
// },
// 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");
/**
* 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/2022-12-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
from azure.identity import DefaultAzureCredential
from azure.mgmt.rdbms import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-rdbms
# 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/2022-12-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
示例响应
{
"sku": {
"name": "Standard_D4s_v3",
"tier": "GeneralPurpose"
},
"properties": {
"fullyQualifiedDomainName": "c7d7483a8ceb.test-private-dns-zone.postgres.database.azure.com",
"version": "14",
"minorVersion": "6",
"administratorLogin": "cloudsa",
"state": "Ready",
"availabilityZone": "1",
"storage": {
"storageSizeGB": 512
},
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2021-05-26T01:16:58.3723361+00:00"
},
"network": {
"publicNetworkAccess": "Disabled",
"delegatedSubnetResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet",
"privateDnsZoneArmResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"
},
"highAvailability": {
"mode": "ZoneRedundant",
"state": "Healthy",
"standbyAvailabilityZone": "2"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
}
},
"location": "westus",
"tags": {
"ElasticServer": "1"
},
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc4",
"name": "pgtestsvc4",
"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=2022-12-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=2022-12-01
定义
activeDirectoryAuthEnum
如果已启用,则启用 Azure Active Directory 身份验证。
名称 |
类型 |
说明 |
Disabled
|
string
|
|
Enabled
|
string
|
|
ArmServerKeyType
用于描述它是系统托管还是 Azure 密钥保管库的数据加密类型。
名称 |
类型 |
说明 |
AzureKeyVault
|
string
|
|
SystemManaged
|
string
|
|
AuthConfig
服务器的 AuthConfig 属性。
Backup
服务器的备份属性。
名称 |
类型 |
默认值 |
说明 |
backupRetentionDays
|
integer
|
7
|
服务器的备份保留天数。
|
earliestRestoreDate
|
string
|
|
服务器的最早还原点时间 (ISO8601) 格式。
|
geoRedundantBackup
|
GeoRedundantBackupEnum
|
Disabled
|
一个 值,该值指示服务器上是否启用了 Geo-Redundant 备份。
|
createdByType
创建资源的标识类型。
名称 |
类型 |
说明 |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
CreateMode
创建新 PostgreSQL 服务器的模式。
名称 |
类型 |
说明 |
Create
|
string
|
|
Default
|
string
|
|
GeoRestore
|
string
|
|
PointInTimeRestore
|
string
|
|
Replica
|
string
|
|
Update
|
string
|
|
CreateModeForUpdate
更新新 PostgreSQL 服务器的模式。
名称 |
类型 |
说明 |
Default
|
string
|
|
Update
|
string
|
|
DataEncryption
服务器的数据加密属性。
名称 |
类型 |
说明 |
primaryKeyURI
|
string
|
主服务器数据加密密钥的 URI。
|
primaryUserAssignedIdentityId
|
string
|
要用于主服务器数据加密的用户分配标识的资源 ID。
|
type
|
ArmServerKeyType
|
数据加密类型,用于描述它是系统托管还是 Azure Key Vault。
|
ErrorAdditionalInfo
资源管理错误附加信息。
名称 |
类型 |
说明 |
info
|
object
|
其他信息。
|
type
|
string
|
其他信息类型。
|
ErrorDetail
错误详细信息。
ErrorResponse
错误响应
GeoRedundantBackupEnum
一个 值,该值指示服务器上是否启用了 Geo-Redundant 备份。
名称 |
类型 |
说明 |
Disabled
|
string
|
|
Enabled
|
string
|
|
HighAvailability
服务器的高可用性属性。
HighAvailabilityMode
服务器的 HA 模式。
名称 |
类型 |
说明 |
Disabled
|
string
|
|
SameZone
|
string
|
|
ZoneRedundant
|
string
|
|
IdentityType
与此资源关联的标识类型;当前限制为“None 和 UserAssigned”
名称 |
类型 |
说明 |
None
|
string
|
|
UserAssigned
|
string
|
|
MaintenanceWindow
服务器的维护时段属性。
名称 |
类型 |
默认值 |
说明 |
customWindow
|
string
|
Disabled
|
指示是启用或禁用自定义窗口
|
dayOfWeek
|
integer
|
0
|
维护时段的星期数
|
startHour
|
integer
|
0
|
维护时段的开始时间
|
startMinute
|
integer
|
0
|
维护时段的开始分钟数
|
Network
服务器的网络属性。 仅当希望服务器为专用访问服务器时,才需要传递此 Network 属性。
名称 |
类型 |
说明 |
delegatedSubnetResourceId
|
string
|
委托的子网 arm 资源 ID。如果我们希望服务器注入 VNET(即专用访问服务器),则需要在创建过程中传递此项。 在更新期间,仅当我们想要更新专用 DNS区域的值时,才传递此项。
|
privateDnsZoneArmResourceId
|
string
|
专用 DNS 区域 arm 资源 ID。如果我们希望服务器注入 VNET(即专用访问服务器),则需要在创建过程中传递此项。 在更新期间,仅当我们想要更新专用 DNS区域的值时,才传递此项。
|
publicNetworkAccess
|
ServerPublicNetworkAccessState
|
是否启用公用网络访问
|
passwordAuthEnum
如果已启用,则启用密码身份验证。
名称 |
类型 |
说明 |
Disabled
|
string
|
|
Enabled
|
string
|
|
ReplicationRole
服务器的复制角色
名称 |
类型 |
说明 |
AsyncReplica
|
string
|
|
GeoAsyncReplica
|
string
|
|
None
|
string
|
|
Primary
|
string
|
|
Server
表示服务器。
名称 |
类型 |
说明 |
id
|
string
|
资源的完全限定的资源 ID。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
identity
|
UserAssignedIdentity
|
描述应用程序的标识。
|
location
|
string
|
资源所在的地理位置
|
name
|
string
|
资源的名称
|
properties.administratorLogin
|
string
|
服务器的管理员登录名。 只能在 (创建服务器时指定,并且需要创建) 。
|
properties.administratorLoginPassword
|
string
|
创建服务器) (管理员登录密码。
|
properties.authConfig
|
AuthConfig
|
服务器的 AuthConfig 属性。
|
properties.availabilityZone
|
string
|
服务器的可用性区域信息。
|
properties.backup
|
Backup
|
服务器的备份属性。
|
properties.createMode
|
CreateMode
|
用于创建新的 PostgreSQL 服务器的模式。
|
properties.dataEncryption
|
DataEncryption
|
服务器的数据加密属性。
|
properties.fullyQualifiedDomainName
|
string
|
服务器的完全限定域名。
|
properties.highAvailability
|
HighAvailability
|
服务器的高可用性属性。
|
properties.maintenanceWindow
|
MaintenanceWindow
|
服务器的维护时段属性。
|
properties.minorVersion
|
string
|
服务器的次要版本。
|
properties.network
|
Network
|
服务器的网络属性。 仅当希望服务器为专用访问服务器时,才需要传递此 Network 属性。
|
properties.pointInTimeUTC
|
string
|
还原点创建时间 (ISO8601 格式) ,指定要从其还原的时间。 当“createMode”为“PointInTimeRestore”或“GeoRestore”时,这是必需的。
|
properties.replicaCapacity
|
integer
|
服务器允许的副本。
|
properties.replicationRole
|
ReplicationRole
|
服务器的复制角色
|
properties.sourceServerResourceId
|
string
|
要从中还原的源服务器资源 ID。 当“createMode”为“PointInTimeRestore”、“GeoRestore”或“Replica”时,这是必需的。 此属性仅为副本服务器返回
|
properties.state
|
ServerState
|
用户可见的服务器的状态。
|
properties.storage
|
Storage
|
服务器的存储属性。
|
properties.version
|
ServerVersion
|
PostgreSQL 服务器版本。
|
sku
|
Sku
|
服务器的 SKU (定价层) 。
|
systemData
|
systemData
|
与此资源相关的系统元数据。
|
tags
|
object
|
资源标记。
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
ServerForUpdate
更新服务器所需的参数。
ServerHAState
对用户可见的 HA 服务器的状态。
名称 |
类型 |
说明 |
CreatingStandby
|
string
|
|
FailingOver
|
string
|
|
Healthy
|
string
|
|
NotEnabled
|
string
|
|
RemovingStandby
|
string
|
|
ReplicatingData
|
string
|
|
ServerPublicNetworkAccessState
是否启用公用网络访问
名称 |
类型 |
说明 |
Disabled
|
string
|
|
Enabled
|
string
|
|
ServerState
用户可见的服务器的状态。
名称 |
类型 |
说明 |
Disabled
|
string
|
|
Dropping
|
string
|
|
Ready
|
string
|
|
Starting
|
string
|
|
Stopped
|
string
|
|
Stopping
|
string
|
|
Updating
|
string
|
|
ServerVersion
PostgreSQL 服务器版本。
名称 |
类型 |
说明 |
11
|
string
|
|
12
|
string
|
|
13
|
string
|
|
14
|
string
|
|
Sku
服务器的 SKU (定价层) 。
名称 |
类型 |
说明 |
name
|
string
|
sku 的名称,通常为层 + 系列 + 核心,例如Standard_D4s_v3。
|
tier
|
SkuTier
|
特定 SKU 的层,例如可突发。
|
SkuTier
特定 SKU 的层,例如可突发。
名称 |
类型 |
说明 |
Burstable
|
string
|
|
GeneralPurpose
|
string
|
|
MemoryOptimized
|
string
|
|
Storage
服务器的存储属性。
名称 |
类型 |
说明 |
storageSizeGB
|
integer
|
服务器允许的最大存储。
|
systemData
与此资源相关的系统元数据。
名称 |
类型 |
说明 |
createdAt
|
string
|
资源的创建时间戳 (UTC) 。
|
createdBy
|
string
|
创建资源的标识。
|
createdByType
|
createdByType
|
创建资源的标识类型。
|
lastModifiedAt
|
string
|
资源上次修改的时间戳 (UTC)
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识类型。
|
UserAssignedIdentity
描述应用程序的标识。
名称 |
类型 |
说明 |
tenantId
|
string
|
服务器的租户 ID。
|
type
|
IdentityType
|
与此资源关联的标识类型;当前限制为“None 和 UserAssigned”
|
userAssignedIdentities
|
<string,
UserIdentity>
|
表示用户分配的标识映射。
|
UserIdentity
描述与应用程序关联的单个用户分配标识。
名称 |
类型 |
说明 |
clientId
|
string
|
此标识表示的服务主体的客户端标识符。
|
principalId
|
string
|
此标识表示的服务主体的对象标识符。
|