Met à jour un serveur existant. Le corps de la requête peut contenir une à plusieurs des propriétés présentes dans la définition de serveur normale.
PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}?api-version=2022-12-01
Paramètres URI
Nom |
Dans |
Obligatoire |
Type |
Description |
resourceGroupName
|
path |
True
|
string
|
Nom du groupe de ressources. Le nom ne respecte pas la casse.
|
serverName
|
path |
True
|
string
|
Le nom du serveur
Modèle d’expression régulière: ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*
|
subscriptionId
|
path |
True
|
string
|
ID de l’abonnement cible.
|
api-version
|
query |
True
|
string
|
Version de l’API à utiliser pour cette opération.
|
Corps de la demande
Nom |
Type |
Description |
parameters
|
ServerForUpdate
|
Paramètres requis pour la mise à jour d’un serveur.
|
Réponses
Nom |
Type |
Description |
200 OK
|
Server
|
Ok
|
202 Accepted
|
|
Accepté
En-têtes
Location: string
|
Other Status Codes
|
ErrorResponse
|
Réponse d’erreur décrivant la raison de l’échec de l’opération.
|
Sécurité
azure_auth
Flux OAuth2 Azure Active Directory
Type:
oauth2
Flux:
implicit
URL d’autorisation:
https://login.microsoftonline.com/common/oauth2/authorize
Étendues
Nom |
Description |
user_impersonation
|
Emprunter l’identité de votre compte d’utilisateur
|
Exemples
ServerUpdate
Exemple de requête
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
Exemple de réponse
{
"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
Exemple de requête
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
Exemple de réponse
{
"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
Exemple de requête
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
Exemple de réponse
{
"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
Exemple de requête
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
Exemple de réponse
{
"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
Exemple de requête
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
Exemple de réponse
{
"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
Définitions
Nom |
Description |
activeDirectoryAuthEnum
|
Si cette option est activée, l’authentification Azure Active Directory est activée.
|
ArmServerKeyType
|
Type de chiffrement de données pour représenter s’il s’agit d’un coffre de clés géré par le système ou d’Azure Key Vault.
|
AuthConfig
|
Propriétés AuthConfig d’un serveur.
|
Backup
|
Propriétés de sauvegarde d’un serveur.
|
createdByType
|
Type d’identité qui a créé la ressource.
|
CreateMode
|
Mode de création d’un serveur PostgreSQL.
|
CreateModeForUpdate
|
Mode de mise à jour d’un nouveau serveur PostgreSQL.
|
DataEncryption
|
Propriétés de chiffrement des données d’un serveur.
|
ErrorAdditionalInfo
|
Informations supplémentaires sur l’erreur de gestion des ressources.
|
ErrorDetail
|
Détail de l’erreur.
|
ErrorResponse
|
Réponse d’erreur
|
GeoRedundantBackupEnum
|
Valeur indiquant si Geo-Redundant sauvegarde est activée sur le serveur.
|
HighAvailability
|
Propriétés de haute disponibilité d’un serveur.
|
HighAvailabilityMode
|
Mode haute disponibilité pour le serveur.
|
IdentityType
|
les types d’identités associés à cette ressource ; actuellement limité à « None and UserAssigned »
|
MaintenanceWindow
|
Propriétés de la fenêtre de maintenance d’un serveur.
|
Network
|
Propriétés réseau d’un serveur. Cette propriété Réseau doit être transmise uniquement si vous souhaitez que le serveur soit un serveur d’accès privé.
|
passwordAuthEnum
|
Si cette option est activée, l’authentification par mot de passe est activée.
|
ReplicationRole
|
Rôle de réplication du serveur
|
Server
|
Représente un serveur.
|
ServerForUpdate
|
Paramètres requis pour la mise à jour d’un serveur.
|
ServerHAState
|
État d’un serveur haute disponibilité visible par l’utilisateur.
|
ServerPublicNetworkAccessState
|
l’accès au réseau public est activé ou non
|
ServerState
|
État d’un serveur visible par l’utilisateur.
|
ServerVersion
|
Version du serveur PostgreSQL.
|
Sku
|
Référence SKU (niveau tarifaire) du serveur.
|
SkuTier
|
Niveau de la référence SKU particulière, par exemple Burstable.
|
Storage
|
Propriétés de stockage d’un serveur.
|
systemData
|
Métadonnées système relatives à cette ressource.
|
UserAssignedIdentity
|
Décrit l’identité de l’application.
|
UserIdentity
|
Décrit une identité affectée par l’utilisateur unique associée à l’application.
|
activeDirectoryAuthEnum
Si cette option est activée, l’authentification Azure Active Directory est activée.
Nom |
Type |
Description |
Disabled
|
string
|
|
Enabled
|
string
|
|
ArmServerKeyType
Type de chiffrement de données pour représenter s’il s’agit d’un coffre de clés géré par le système ou d’Azure Key Vault.
Nom |
Type |
Description |
AzureKeyVault
|
string
|
|
SystemManaged
|
string
|
|
AuthConfig
Propriétés AuthConfig d’un serveur.
Nom |
Type |
Valeur par défaut |
Description |
activeDirectoryAuth
|
activeDirectoryAuthEnum
|
|
Si cette option est activée, l’authentification Azure Active Directory est activée.
|
passwordAuth
|
passwordAuthEnum
|
Enabled
|
Si cette option est activée, l’authentification par mot de passe est activée.
|
tenantId
|
string
|
|
ID de locataire du serveur.
|
Backup
Propriétés de sauvegarde d’un serveur.
Nom |
Type |
Valeur par défaut |
Description |
backupRetentionDays
|
integer
|
7
|
Jours de rétention de sauvegarde pour le serveur.
|
earliestRestoreDate
|
string
|
|
Heure de point de restauration la plus ancienne (format ISO8601) pour le serveur.
|
geoRedundantBackup
|
GeoRedundantBackupEnum
|
Disabled
|
Valeur indiquant si Geo-Redundant sauvegarde est activée sur le serveur.
|
createdByType
Type d’identité qui a créé la ressource.
Nom |
Type |
Description |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
CreateMode
Mode de création d’un serveur PostgreSQL.
Nom |
Type |
Description |
Create
|
string
|
|
Default
|
string
|
|
GeoRestore
|
string
|
|
PointInTimeRestore
|
string
|
|
Replica
|
string
|
|
Update
|
string
|
|
CreateModeForUpdate
Mode de mise à jour d’un nouveau serveur PostgreSQL.
Nom |
Type |
Description |
Default
|
string
|
|
Update
|
string
|
|
DataEncryption
Propriétés de chiffrement des données d’un serveur.
Nom |
Type |
Description |
primaryKeyURI
|
string
|
URI de la clé pour le chiffrement des données pour le serveur principal.
|
primaryUserAssignedIdentityId
|
string
|
ID de ressource de l’identité affectée par l’utilisateur à utiliser pour le chiffrement des données pour le serveur principal.
|
type
|
ArmServerKeyType
|
Type de chiffrement de données pour représenter s’il s’agit d’un coffre de clés géré par le système ou d’Azure Key Vault.
|
ErrorAdditionalInfo
Informations supplémentaires sur l’erreur de gestion des ressources.
Nom |
Type |
Description |
info
|
object
|
Informations supplémentaires
|
type
|
string
|
Type d’informations supplémentaires.
|
ErrorDetail
Détail de l’erreur.
Nom |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Informations supplémentaires sur l’erreur.
|
code
|
string
|
Code d'erreur.
|
details
|
ErrorDetail[]
|
Détails de l’erreur.
|
message
|
string
|
Message d’erreur.
|
target
|
string
|
Cible d’erreur.
|
ErrorResponse
Réponse d’erreur
GeoRedundantBackupEnum
Valeur indiquant si Geo-Redundant sauvegarde est activée sur le serveur.
Nom |
Type |
Description |
Disabled
|
string
|
|
Enabled
|
string
|
|
HighAvailability
Propriétés de haute disponibilité d’un serveur.
Nom |
Type |
Valeur par défaut |
Description |
mode
|
HighAvailabilityMode
|
Disabled
|
Mode haute disponibilité pour le serveur.
|
standbyAvailabilityZone
|
string
|
|
informations sur la zone de disponibilité du serveur de secours.
|
state
|
ServerHAState
|
|
État d’un serveur haute disponibilité visible par l’utilisateur.
|
HighAvailabilityMode
Mode haute disponibilité pour le serveur.
Nom |
Type |
Description |
Disabled
|
string
|
|
SameZone
|
string
|
|
ZoneRedundant
|
string
|
|
IdentityType
les types d’identités associés à cette ressource ; actuellement limité à « None and UserAssigned »
Nom |
Type |
Description |
None
|
string
|
|
UserAssigned
|
string
|
|
MaintenanceWindow
Propriétés de la fenêtre de maintenance d’un serveur.
Nom |
Type |
Valeur par défaut |
Description |
customWindow
|
string
|
Disabled
|
indique si la fenêtre personnalisée est activée ou désactivée
|
dayOfWeek
|
integer
|
0
|
jour de la semaine pour la fenêtre de maintenance
|
startHour
|
integer
|
0
|
heure de début pour la fenêtre de maintenance
|
startMinute
|
integer
|
0
|
minute de démarrage pour la fenêtre de maintenance
|
Network
Propriétés réseau d’un serveur. Cette propriété Réseau doit être transmise uniquement si vous souhaitez que le serveur soit un serveur d’accès privé.
Nom |
Type |
Description |
delegatedSubnetResourceId
|
string
|
ID de ressource du sous-réseau délégué. Cette opération doit être transmise lors de la création, dans le cas où nous voulons que le serveur soit injecté sur un réseau virtuel, c’est-à-dire un serveur d’accès privé. Pendant la mise à jour, transmettez-le uniquement si nous voulons mettre à jour la valeur de DNS privé zone.
|
privateDnsZoneArmResourceId
|
string
|
ID de ressource arm de zone DNS privée. Cette opération doit être transmise lors de la création, dans le cas où nous voulons que le serveur soit injecté sur un réseau virtuel, c’est-à-dire un serveur d’accès privé. Pendant la mise à jour, transmettez-le uniquement si nous voulons mettre à jour la valeur de DNS privé zone.
|
publicNetworkAccess
|
ServerPublicNetworkAccessState
|
l’accès au réseau public est activé ou non
|
passwordAuthEnum
Si cette option est activée, l’authentification par mot de passe est activée.
Nom |
Type |
Description |
Disabled
|
string
|
|
Enabled
|
string
|
|
ReplicationRole
Rôle de réplication du serveur
Nom |
Type |
Description |
AsyncReplica
|
string
|
|
GeoAsyncReplica
|
string
|
|
None
|
string
|
|
Primary
|
string
|
|
Server
Représente un serveur.
Nom |
Type |
Description |
id
|
string
|
ID de ressource complet pour la ressource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
identity
|
UserAssignedIdentity
|
Décrit l’identité de l’application.
|
location
|
string
|
Emplacement géographique où réside la ressource
|
name
|
string
|
nom de la ressource.
|
properties.administratorLogin
|
string
|
Nom de connexion de l’administrateur d’un serveur. Ne peut être spécifié que lorsque le serveur est en cours de création (et est requis pour la création).
|
properties.administratorLoginPassword
|
string
|
Mot de passe de connexion administrateur (requis pour la création du serveur).
|
properties.authConfig
|
AuthConfig
|
Propriétés AuthConfig d’un serveur.
|
properties.availabilityZone
|
string
|
informations sur la zone de disponibilité du serveur.
|
properties.backup
|
Backup
|
Propriétés de sauvegarde d’un serveur.
|
properties.createMode
|
CreateMode
|
Mode de création d’un serveur PostgreSQL.
|
properties.dataEncryption
|
DataEncryption
|
Propriétés de chiffrement des données d’un serveur.
|
properties.fullyQualifiedDomainName
|
string
|
Nom de domaine complet d’un serveur.
|
properties.highAvailability
|
HighAvailability
|
Propriétés de haute disponibilité d’un serveur.
|
properties.maintenanceWindow
|
MaintenanceWindow
|
Propriétés de la fenêtre de maintenance d’un serveur.
|
properties.minorVersion
|
string
|
Version mineure du serveur.
|
properties.network
|
Network
|
Propriétés réseau d’un serveur. Cette propriété Réseau doit être transmise uniquement si vous souhaitez que le serveur soit un serveur d’accès privé.
|
properties.pointInTimeUTC
|
string
|
Heure de création du point de restauration (format ISO8601), en spécifiant l’heure à partir de laquelle effectuer la restauration. Elle est obligatoire lorsque « createMode » est « PointInTimeRestore » ou « GeoRestore ».
|
properties.replicaCapacity
|
integer
|
Réplicas autorisés pour un serveur.
|
properties.replicationRole
|
ReplicationRole
|
Rôle de réplication du serveur
|
properties.sourceServerResourceId
|
string
|
ID de ressource du serveur source à partir duquel effectuer la restauration. Elle est obligatoire lorsque « createMode » est « PointInTimeRestore » ou « GeoRestore » ou « Réplica ». Cette propriété est retournée uniquement pour le serveur réplica
|
properties.state
|
ServerState
|
État d’un serveur visible par l’utilisateur.
|
properties.storage
|
Storage
|
Propriétés de stockage d’un serveur.
|
properties.version
|
ServerVersion
|
Version du serveur PostgreSQL.
|
sku
|
Sku
|
Référence SKU (niveau tarifaire) du serveur.
|
systemData
|
systemData
|
Métadonnées système relatives à cette ressource.
|
tags
|
object
|
Balises de ressource.
|
type
|
string
|
Type de la ressource. Par exemple, « Microsoft.Compute/virtualMachines » ou « Microsoft.Storage/storageAccounts »
|
ServerForUpdate
Paramètres requis pour la mise à jour d’un serveur.
Nom |
Type |
Description |
identity
|
UserAssignedIdentity
|
Décrit l’identité de l’application.
|
properties.administratorLoginPassword
|
string
|
Mot de passe de la connexion administrateur.
|
properties.authConfig
|
AuthConfig
|
Propriétés AuthConfig d’un serveur.
|
properties.backup
|
Backup
|
Propriétés de sauvegarde d’un serveur.
|
properties.createMode
|
CreateModeForUpdate
|
Mode de mise à jour d’un nouveau serveur PostgreSQL.
|
properties.dataEncryption
|
DataEncryption
|
Propriétés de chiffrement des données d’un serveur.
|
properties.highAvailability
|
HighAvailability
|
Propriétés de haute disponibilité d’un serveur.
|
properties.maintenanceWindow
|
MaintenanceWindow
|
Propriétés de la fenêtre de maintenance d’un serveur.
|
properties.network
|
Network
|
Propriétés réseau d’un serveur. Celles-ci doivent être transmises uniquement dans le cas où le serveur est un serveur d’accès privé.
|
properties.replicationRole
|
ReplicationRole
|
Rôle de réplication du serveur
|
properties.storage
|
Storage
|
Propriétés de stockage d’un serveur.
|
properties.version
|
ServerVersion
|
Version du serveur PostgreSQL.
|
sku
|
Sku
|
Référence SKU (niveau tarifaire) du serveur.
|
tags
|
object
|
Métadonnées spécifiques d’application sous la forme de paires clé/valeur.
|
ServerHAState
État d’un serveur haute disponibilité visible par l’utilisateur.
Nom |
Type |
Description |
CreatingStandby
|
string
|
|
FailingOver
|
string
|
|
Healthy
|
string
|
|
NotEnabled
|
string
|
|
RemovingStandby
|
string
|
|
ReplicatingData
|
string
|
|
ServerPublicNetworkAccessState
l’accès au réseau public est activé ou non
Nom |
Type |
Description |
Disabled
|
string
|
|
Enabled
|
string
|
|
ServerState
État d’un serveur visible par l’utilisateur.
Nom |
Type |
Description |
Disabled
|
string
|
|
Dropping
|
string
|
|
Ready
|
string
|
|
Starting
|
string
|
|
Stopped
|
string
|
|
Stopping
|
string
|
|
Updating
|
string
|
|
ServerVersion
Version du serveur PostgreSQL.
Nom |
Type |
Description |
11
|
string
|
|
12
|
string
|
|
13
|
string
|
|
14
|
string
|
|
Sku
Référence SKU (niveau tarifaire) du serveur.
Nom |
Type |
Description |
name
|
string
|
Nom de la référence sku, généralement niveau + famille + cœurs, par exemple Standard_D4s_v3.
|
tier
|
SkuTier
|
Niveau de la référence SKU particulière, par exemple Burstable.
|
SkuTier
Niveau de la référence SKU particulière, par exemple Burstable.
Nom |
Type |
Description |
Burstable
|
string
|
|
GeneralPurpose
|
string
|
|
MemoryOptimized
|
string
|
|
Storage
Propriétés de stockage d’un serveur.
Nom |
Type |
Description |
storageSizeGB
|
integer
|
Stockage maximal autorisé pour un serveur.
|
systemData
Métadonnées système relatives à cette ressource.
Nom |
Type |
Description |
createdAt
|
string
|
Horodatage de la création de ressources (UTC).
|
createdBy
|
string
|
Identité qui a créé la ressource.
|
createdByType
|
createdByType
|
Type d’identité qui a créé la ressource.
|
lastModifiedAt
|
string
|
Horodatage de la dernière modification de la ressource (UTC)
|
lastModifiedBy
|
string
|
Identité qui a modifié la dernière ressource.
|
lastModifiedByType
|
createdByType
|
Type d’identité qui a modifié la dernière ressource.
|
UserAssignedIdentity
Décrit l’identité de l’application.
Nom |
Type |
Description |
tenantId
|
string
|
ID de locataire du serveur.
|
type
|
IdentityType
|
les types d’identités associés à cette ressource ; actuellement limité à « None and UserAssigned »
|
userAssignedIdentities
|
<string,
UserIdentity>
|
représente la carte des identités affectées par l’utilisateur.
|
UserIdentity
Décrit une identité affectée par l’utilisateur unique associée à l’application.
Nom |
Type |
Description |
clientId
|
string
|
identificateur client du principal de service que cette identité représente.
|
principalId
|
string
|
identificateur d’objet du principal de service que cette identité représente.
|