Aktualizacje istniejącego serwera. Treść żądania może zawierać od jednej do wielu właściwości znajdujących się w normalnej definicji serwera.
PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}?api-version=2022-12-01
Parametry identyfikatora URI
Nazwa |
W |
Wymagane |
Typ |
Opis |
resourceGroupName
|
path |
True
|
string
|
Nazwa grupy zasobów. W nazwie jest uwzględniana wielkość liter.
|
serverName
|
path |
True
|
string
|
Nazwa serwera.
Wzorzec wyrażenia regularnego: ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*
|
subscriptionId
|
path |
True
|
string
|
Identyfikator subskrypcji docelowej.
|
api-version
|
query |
True
|
string
|
Wersja interfejsu API do użycia dla tej operacji.
|
Treść żądania
Nazwa |
Typ |
Opis |
parameters
|
ServerForUpdate
|
Wymagane parametry do aktualizowania serwera.
|
Odpowiedzi
Nazwa |
Typ |
Opis |
200 OK
|
Server
|
OK
|
202 Accepted
|
|
Zaakceptowano
Nagłówki
Location: string
|
Other Status Codes
|
ErrorResponse
|
Odpowiedź na błąd opisująca, dlaczego operacja nie powiodła się.
|
Zabezpieczenia
azure_auth
Przepływ OAuth2 usługi Azure Active Directory
Typ:
oauth2
Flow:
implicit
Adres URL autoryzacji:
https://login.microsoftonline.com/common/oauth2/authorize
Zakresy
Nazwa |
Opis |
user_impersonation
|
personifikacja konta użytkownika
|
Przykłady
ServerUpdate
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Przykładowe żądanie
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
Przykładowa odpowiedź
{
"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
Definicje
activeDirectoryAuthEnum
W przypadku włączenia uwierzytelniania usługi Azure Active Directory jest włączone.
Nazwa |
Typ |
Opis |
Disabled
|
string
|
|
Enabled
|
string
|
|
ArmServerKeyType
Typ szyfrowania danych do przedstawienia, czy jest zarządzany przez system, a usługa Azure Key Vault.
Nazwa |
Typ |
Opis |
AzureKeyVault
|
string
|
|
SystemManaged
|
string
|
|
AuthConfig
Właściwości AuthConfig serwera.
Nazwa |
Typ |
Domyślna wartość |
Opis |
activeDirectoryAuth
|
activeDirectoryAuthEnum
|
|
W przypadku włączenia uwierzytelniania usługi Azure Active Directory jest włączone.
|
passwordAuth
|
passwordAuthEnum
|
Enabled
|
W przypadku włączenia uwierzytelniania haseł jest włączone.
|
tenantId
|
string
|
|
Identyfikator dzierżawy serwera.
|
Backup
Właściwości kopii zapasowej serwera.
Nazwa |
Typ |
Domyślna wartość |
Opis |
backupRetentionDays
|
integer
|
7
|
Dni przechowywania kopii zapasowej serwera.
|
earliestRestoreDate
|
string
|
|
Najwcześniejszy format punktu przywracania (format ISO8601) dla serwera.
|
geoRedundantBackup
|
GeoRedundantBackupEnum
|
Disabled
|
Wartość wskazująca, czy na serwerze jest włączona Geo-Redundant kopia zapasowa.
|
createdByType
Typ tożsamości, która utworzyła zasób.
Nazwa |
Typ |
Opis |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
CreateMode
Tryb tworzenia nowego serwera PostgreSQL.
Nazwa |
Typ |
Opis |
Create
|
string
|
|
Default
|
string
|
|
GeoRestore
|
string
|
|
PointInTimeRestore
|
string
|
|
Replica
|
string
|
|
Update
|
string
|
|
CreateModeForUpdate
Tryb aktualizowania nowego serwera PostgreSQL.
Nazwa |
Typ |
Opis |
Default
|
string
|
|
Update
|
string
|
|
DataEncryption
Właściwości szyfrowania danych serwera.
Nazwa |
Typ |
Opis |
primaryKeyURI
|
string
|
Identyfikator URI klucza szyfrowania danych dla serwera podstawowego.
|
primaryUserAssignedIdentityId
|
string
|
Identyfikator zasobu tożsamości przypisanej przez użytkownika, która ma być używana do szyfrowania danych na serwerze podstawowym.
|
type
|
ArmServerKeyType
|
Typ szyfrowania danych do przedstawienia, czy jest zarządzany przez system, a usługa Azure Key Vault.
|
ErrorAdditionalInfo
Dodatkowe informacje o błędzie zarządzania zasobami.
Nazwa |
Typ |
Opis |
info
|
object
|
Dodatkowe informacje.
|
type
|
string
|
Dodatkowy typ informacji.
|
ErrorDetail
Szczegóły błędu.
Nazwa |
Typ |
Opis |
additionalInfo
|
ErrorAdditionalInfo[]
|
Dodatkowe informacje o błędzie.
|
code
|
string
|
Kod błędu.
|
details
|
ErrorDetail[]
|
Szczegóły błędu.
|
message
|
string
|
Komunikat o błędzie.
|
target
|
string
|
Element docelowy błędu.
|
ErrorResponse
Odpowiedź na błąd
GeoRedundantBackupEnum
Wartość wskazująca, czy na serwerze jest włączona Geo-Redundant kopia zapasowa.
Nazwa |
Typ |
Opis |
Disabled
|
string
|
|
Enabled
|
string
|
|
HighAvailability
Właściwości wysokiej dostępności serwera.
Nazwa |
Typ |
Domyślna wartość |
Opis |
mode
|
HighAvailabilityMode
|
Disabled
|
Tryb wysokiej dostępności serwera.
|
standbyAvailabilityZone
|
string
|
|
informacje o strefie dostępności rezerwowego.
|
state
|
ServerHAState
|
|
Stan serwera wysokiej dostępności, który jest widoczny dla użytkownika.
|
HighAvailabilityMode
Tryb wysokiej dostępności serwera.
Nazwa |
Typ |
Opis |
Disabled
|
string
|
|
SameZone
|
string
|
|
ZoneRedundant
|
string
|
|
IdentityType
typy tożsamości skojarzonych z tym zasobem; obecnie ograniczone do parametru "None and UserAssigned"
Nazwa |
Typ |
Opis |
None
|
string
|
|
UserAssigned
|
string
|
|
MaintenanceWindow
Właściwości okna obsługi serwera.
Nazwa |
Typ |
Domyślna wartość |
Opis |
customWindow
|
string
|
Disabled
|
wskazuje, czy okno niestandardowe jest włączone, czy wyłączone
|
dayOfWeek
|
integer
|
0
|
dzień tygodnia dla okna obsługi
|
startHour
|
integer
|
0
|
godzina rozpoczęcia okna obsługi
|
startMinute
|
integer
|
0
|
minuta rozpoczęcia okna obsługi
|
Network
Właściwości sieci serwera. Ta właściwość sieci jest wymagana do przekazania tylko w przypadku, gdy serwer ma być serwerem dostępu prywatnego.
Nazwa |
Typ |
Opis |
delegatedSubnetResourceId
|
string
|
Identyfikator zasobu arm delegowanej podsieci. Jest to wymagane do przekazania podczas tworzenia, jeśli chcemy, aby serwer był wstrzykiwany do sieci wirtualnej, tj. serwer dostępu prywatnego. Podczas aktualizacji przekaż tę wartość tylko wtedy, gdy chcemy zaktualizować wartość strefy Prywatna strefa DNS.
|
privateDnsZoneArmResourceId
|
string
|
Identyfikator zasobu arm prywatnej strefy DNS. Jest to wymagane do przekazania podczas tworzenia, jeśli chcemy, aby serwer był wstrzykiwany do sieci wirtualnej, tj. serwer dostępu prywatnego. Podczas aktualizacji przekaż tę wartość tylko wtedy, gdy chcemy zaktualizować wartość strefy Prywatna strefa DNS.
|
publicNetworkAccess
|
ServerPublicNetworkAccessState
|
dostęp do sieci publicznej jest włączony lub nie
|
passwordAuthEnum
W przypadku włączenia uwierzytelniania haseł jest włączone.
Nazwa |
Typ |
Opis |
Disabled
|
string
|
|
Enabled
|
string
|
|
ReplicationRole
Rola replikacji serwera
Nazwa |
Typ |
Opis |
AsyncReplica
|
string
|
|
GeoAsyncReplica
|
string
|
|
None
|
string
|
|
Primary
|
string
|
|
Server
Reprezentuje serwer.
Nazwa |
Typ |
Opis |
id
|
string
|
W pełni kwalifikowany identyfikator zasobu dla zasobu. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
identity
|
UserAssignedIdentity
|
Opisuje tożsamość aplikacji.
|
location
|
string
|
Lokalizacja geograficzna, w której znajduje się zasób
|
name
|
string
|
Nazwa zasobu
|
properties.administratorLogin
|
string
|
Nazwa logowania administratora serwera. Można określić tylko wtedy, gdy serwer jest tworzony (i jest wymagany do utworzenia).
|
properties.administratorLoginPassword
|
string
|
Hasło logowania administratora (wymagane do utworzenia serwera).
|
properties.authConfig
|
AuthConfig
|
Właściwości AuthConfig serwera.
|
properties.availabilityZone
|
string
|
informacje o strefie dostępności serwera.
|
properties.backup
|
Backup
|
Właściwości kopii zapasowej serwera.
|
properties.createMode
|
CreateMode
|
Tryb tworzenia nowego serwera PostgreSQL.
|
properties.dataEncryption
|
DataEncryption
|
Właściwości szyfrowania danych serwera.
|
properties.fullyQualifiedDomainName
|
string
|
W pełni kwalifikowana nazwa domeny serwera.
|
properties.highAvailability
|
HighAvailability
|
Właściwości wysokiej dostępności serwera.
|
properties.maintenanceWindow
|
MaintenanceWindow
|
Właściwości okna obsługi serwera.
|
properties.minorVersion
|
string
|
Wersja pomocnicza serwera.
|
properties.network
|
Network
|
Właściwości sieci serwera. Ta właściwość sieci jest wymagana do przekazania tylko w przypadku, gdy serwer ma być serwerem dostępu prywatnego.
|
properties.pointInTimeUTC
|
string
|
Czas tworzenia punktu przywracania (format ISO8601), określając czas przywracania z. Jest to wymagane, gdy wartość "createMode" to "PointInTimeRestore" lub "GeoRestore".
|
properties.replicaCapacity
|
integer
|
Repliki dozwolone dla serwera.
|
properties.replicationRole
|
ReplicationRole
|
Rola replikacji serwera
|
properties.sourceServerResourceId
|
string
|
Identyfikator zasobu serwera źródłowego do przywrócenia. Jest to wymagane, gdy element "createMode" to "PointInTimeRestore" lub "GeoRestore" lub "Replica". Ta właściwość jest zwracana tylko dla serwera repliki
|
properties.state
|
ServerState
|
Stan serwera, który jest widoczny dla użytkownika.
|
properties.storage
|
Storage
|
Właściwości magazynu serwera.
|
properties.version
|
ServerVersion
|
Wersja serwera PostgreSQL.
|
sku
|
Sku
|
Jednostka SKU (warstwa cenowa) serwera.
|
systemData
|
systemData
|
Metadane systemowe odnoszące się do tego zasobu.
|
tags
|
object
|
Tagi zasobów.
|
type
|
string
|
Typ zasobu. Np. "Microsoft.Compute/virtualMachines" lub "Microsoft.Storage/storageAccounts"
|
ServerForUpdate
Wymagane parametry do aktualizowania serwera.
Nazwa |
Typ |
Opis |
identity
|
UserAssignedIdentity
|
Opisuje tożsamość aplikacji.
|
properties.administratorLoginPassword
|
string
|
Hasło logowania administratora.
|
properties.authConfig
|
AuthConfig
|
Właściwości AuthConfig serwera.
|
properties.backup
|
Backup
|
Właściwości kopii zapasowej serwera.
|
properties.createMode
|
CreateModeForUpdate
|
Tryb aktualizowania nowego serwera PostgreSQL.
|
properties.dataEncryption
|
DataEncryption
|
Właściwości szyfrowania danych serwera.
|
properties.highAvailability
|
HighAvailability
|
Właściwości wysokiej dostępności serwera.
|
properties.maintenanceWindow
|
MaintenanceWindow
|
Właściwości okna obsługi serwera.
|
properties.network
|
Network
|
Właściwości sieci serwera. Są one wymagane do przekazania tylko w przypadku, gdy serwer jest prywatnym serwerem dostępu.
|
properties.replicationRole
|
ReplicationRole
|
Rola replikacji serwera
|
properties.storage
|
Storage
|
Właściwości magazynu serwera.
|
properties.version
|
ServerVersion
|
Wersja serwera PostgreSQL.
|
sku
|
Sku
|
Jednostka SKU (warstwa cenowa) serwera.
|
tags
|
object
|
Metadane specyficzne dla aplikacji w postaci par klucz-wartość.
|
ServerHAState
Stan serwera wysokiej dostępności, który jest widoczny dla użytkownika.
Nazwa |
Typ |
Opis |
CreatingStandby
|
string
|
|
FailingOver
|
string
|
|
Healthy
|
string
|
|
NotEnabled
|
string
|
|
RemovingStandby
|
string
|
|
ReplicatingData
|
string
|
|
ServerPublicNetworkAccessState
dostęp do sieci publicznej jest włączony lub nie
Nazwa |
Typ |
Opis |
Disabled
|
string
|
|
Enabled
|
string
|
|
ServerState
Stan serwera, który jest widoczny dla użytkownika.
Nazwa |
Typ |
Opis |
Disabled
|
string
|
|
Dropping
|
string
|
|
Ready
|
string
|
|
Starting
|
string
|
|
Stopped
|
string
|
|
Stopping
|
string
|
|
Updating
|
string
|
|
ServerVersion
Wersja serwera PostgreSQL.
Nazwa |
Typ |
Opis |
11
|
string
|
|
12
|
string
|
|
13
|
string
|
|
14
|
string
|
|
Sku
Jednostka SKU (warstwa cenowa) serwera.
Nazwa |
Typ |
Opis |
name
|
string
|
Nazwa jednostki SKU, zwykle, warstwa + rodzina i rdzenie, np. Standard_D4s_v3.
|
tier
|
SkuTier
|
Warstwa konkretnej jednostki SKU, np. z możliwością rozszerzenia.
|
SkuTier
Warstwa konkretnej jednostki SKU, np. z możliwością rozszerzenia.
Nazwa |
Typ |
Opis |
Burstable
|
string
|
|
GeneralPurpose
|
string
|
|
MemoryOptimized
|
string
|
|
Storage
Właściwości magazynu serwera.
Nazwa |
Typ |
Opis |
storageSizeGB
|
integer
|
Maksymalny dozwolony magazyn dla serwera.
|
systemData
Metadane systemowe odnoszące się do tego zasobu.
Nazwa |
Typ |
Opis |
createdAt
|
string
|
Sygnatura czasowa tworzenia zasobów (UTC).
|
createdBy
|
string
|
Tożsamość, która utworzyła zasób.
|
createdByType
|
createdByType
|
Typ tożsamości, która utworzyła zasób.
|
lastModifiedAt
|
string
|
Sygnatura czasowa ostatniej modyfikacji zasobu (UTC)
|
lastModifiedBy
|
string
|
Tożsamość, która ostatnio zmodyfikowała zasób.
|
lastModifiedByType
|
createdByType
|
Typ tożsamości, która ostatnio zmodyfikowała zasób.
|
UserAssignedIdentity
Opisuje tożsamość aplikacji.
Nazwa |
Typ |
Opis |
tenantId
|
string
|
Identyfikator dzierżawy serwera.
|
type
|
IdentityType
|
typy tożsamości skojarzonych z tym zasobem; obecnie ograniczone do parametru "None and UserAssigned"
|
userAssignedIdentities
|
<string,
UserIdentity>
|
reprezentuje mapę tożsamości przypisanych przez użytkownika.
|
UserIdentity
Opisuje tożsamość przypisaną przez jednego użytkownika skojarzona z aplikacją.
Nazwa |
Typ |
Opis |
clientId
|
string
|
identyfikator klienta jednostki usługi, którą reprezentuje ta tożsamość.
|
principalId
|
string
|
identyfikator obiektu jednostki usługi, którą reprezentuje ta tożsamość.
|