Creates a new server or updates an existing server. The update action will overwrite the existing server.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}?api-version=2024-12-30
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
The name of the resource group. The name is case insensitive.
|
|
serverName
|
path |
True
|
string
minLength: 1 maxLength: 63 pattern: ^[a-z0-9][-a-z0-9]*(?
|
The name of the server.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
The ID of the target subscription. The value must be an UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Request Body
| Name |
Required |
Type |
Description |
|
location
|
True
|
string
|
The geo-location where the resource lives
|
|
identity
|
|
MySQLServerIdentity
|
The cmk identity for the server.
|
|
properties.administratorLogin
|
|
string
|
The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation).
|
|
properties.administratorLoginPassword
|
|
string
(password)
|
The password of the administrator login (required for server creation).
|
|
properties.availabilityZone
|
|
string
|
availability Zone information of the server.
|
|
properties.backup
|
|
Backup
|
Backup related properties of a server.
|
|
properties.createMode
|
|
CreateMode
|
The mode to create a new MySQL server.
|
|
properties.dataEncryption
|
|
DataEncryption
|
The Data Encryption for CMK.
|
|
properties.databasePort
|
|
integer
(int32)
|
The server database port. Can only be specified when the server is being created.
|
|
properties.highAvailability
|
|
HighAvailability
|
High availability related properties of a server.
|
|
properties.importSourceProperties
|
|
ImportSourceProperties
|
Source properties for import from storage.
|
|
properties.maintenancePolicy
|
|
MaintenancePolicy
|
Maintenance policy of a server.
|
|
properties.maintenanceWindow
|
|
MaintenanceWindow
|
Maintenance window of a server. Known issue: cannot be set during server creation or updated with other properties during server update; must be updated separately.
|
|
properties.network
|
|
Network
|
Network related properties of a server.
|
|
properties.replicationRole
|
|
ReplicationRole
|
The replication role.
|
|
properties.restorePointInTime
|
|
string
(date-time)
|
Restore point creation time (ISO8601 format), specifying the time to restore from.
|
|
properties.sourceServerResourceId
|
|
string
|
The source MySQL server id.
|
|
properties.storage
|
|
Storage
|
Storage related properties of a server.
|
|
properties.version
|
|
ServerVersion
|
Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL 5.7
|
|
sku
|
|
MySQLServerSku
|
The SKU (pricing tier) of the server.
|
|
tags
|
|
object
|
Resource tags.
|
Responses
| Name |
Type |
Description |
|
200 OK
|
Server
|
Resource 'Server' update operation succeeded
|
|
201 Created
|
Server
|
Resource 'Server' create operation succeeded
Headers
- Location: string
- Retry-After: integer
|
|
202 Accepted
|
|
Resource operation accepted.
Headers
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
An unexpected error response.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name |
Description |
|
user_impersonation
|
impersonate your user account
|
Examples
Create a new server
Sample request
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver?api-version=2024-12-30
{
"location": "southeastasia",
"properties": {
"administratorLogin": "cloudsa",
"administratorLoginPassword": "your_password",
"availabilityZone": "1",
"backup": {
"backupIntervalHours": 24,
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"createMode": "Default",
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3"
},
"storage": {
"autoGrow": "Disabled",
"iops": 600,
"storageRedundancy": "ZoneRedundancy",
"storageSizeGB": 100
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.mysqlflexibleservers import MySQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-mysqlflexibleservers
# USAGE
python server_create.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 = MySQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create(
resource_group_name="testrg",
server_name="mysqltestserver",
parameters={
"location": "southeastasia",
"properties": {
"administratorLogin": "cloudsa",
"administratorLoginPassword": "your_password",
"availabilityZone": "1",
"backup": {"backupIntervalHours": 24, "backupRetentionDays": 7, "geoRedundantBackup": "Disabled"},
"createMode": "Default",
"highAvailability": {"mode": "ZoneRedundant", "standbyAvailabilityZone": "3"},
"storage": {
"autoGrow": "Disabled",
"iops": 600,
"storageRedundancy": "ZoneRedundancy",
"storageSizeGB": 100,
},
"version": "5.7",
},
"sku": {"name": "Standard_D2ds_v4", "tier": "GeneralPurpose"},
"tags": {"num": "1"},
},
).result()
print(response)
# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmysqlflexibleservers_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/mysql/armmysqlflexibleservers/v2"
)
// Generated from example definition: 2024-12-30/ServerCreate.json
func ExampleServersClient_BeginCreate_createANewServer() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmysqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.Server{
Location: to.Ptr("southeastasia"),
Properties: &armmysqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("cloudsa"),
AdministratorLoginPassword: to.Ptr("your_password"),
AvailabilityZone: to.Ptr("1"),
Backup: &armmysqlflexibleservers.Backup{
BackupIntervalHours: to.Ptr[int32](24),
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
},
CreateMode: to.Ptr(armmysqlflexibleservers.CreateModeDefault),
HighAvailability: &armmysqlflexibleservers.HighAvailability{
Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant),
StandbyAvailabilityZone: to.Ptr("3"),
},
Storage: &armmysqlflexibleservers.Storage{
AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
Iops: to.Ptr[int32](600),
StorageRedundancy: to.Ptr(armmysqlflexibleservers.StorageRedundancyEnumZoneRedundancy),
StorageSizeGB: to.Ptr[int32](100),
},
Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7),
},
SKU: &armmysqlflexibleservers.MySQLServerSKU{
Name: to.Ptr("Standard_D2ds_v4"),
Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
},
Tags: map[string]*string{
"num": to.Ptr("1"),
},
}, 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 poll 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 = armmysqlflexibleservers.ServersClientCreateResponse{
// Server: armmysqlflexibleservers.Server{
// Name: to.Ptr("mysqltestserver"),
// Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"),
// Location: to.Ptr("Southeast Asia"),
// Properties: &armmysqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AvailabilityZone: to.Ptr("1"),
// Backup: &armmysqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](7),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()),
// GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
// },
// DatabasePort: to.Ptr[int32](3306),
// FullVersion: to.Ptr("5.7.44"),
// FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"),
// HighAvailability: &armmysqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("3"),
// State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateHealthy),
// },
// MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{
// BatchOfMaintenance: to.Ptr(armmysqlflexibleservers.BatchOfMaintenanceDefault),
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// Network: &armmysqlflexibleservers.Network{
// PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// },
// ReplicaCapacity: to.Ptr[int32](10),
// ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone),
// State: to.Ptr(armmysqlflexibleservers.ServerStateReady),
// Storage: &armmysqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// Iops: to.Ptr[int32](600),
// StorageRedundancy: to.Ptr(armmysqlflexibleservers.StorageRedundancyEnumZoneRedundancy),
// StorageSizeGB: to.Ptr[int32](100),
// StorageSKU: to.Ptr("Premium_ZRS"),
// },
// Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7),
// },
// SKU: &armmysqlflexibleservers.MySQLServerSKU{
// Name: to.Ptr("Standard_D2ds_v4"),
// Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
// },
// Tags: map[string]*string{
// "num": to.Ptr("1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.MySql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.MySql.FlexibleServers;
// Generated from example definition: 2024-12-30/ServerCreate.json
// this example is just showing the usage of "Server_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testrg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this MySqlFlexibleServerResource
MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers();
// invoke the operation
string serverName = "mysqltestserver";
MySqlFlexibleServerData data = new MySqlFlexibleServerData(new AzureLocation("southeastasia"))
{
Sku = new MySqlFlexibleServerSku("Standard_D2ds_v4", MySqlFlexibleServerSkuTier.GeneralPurpose),
Tags =
{
["num"] = "1"
},
};
ArmOperation<MySqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
MySqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
MySqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "mysqltestserver",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "cloudsa",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-17T06:11:38.4150019+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 3306,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "mysqltestserver.database.mysql.azure.com",
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3",
"state": "Healthy"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 10,
"replicationRole": "None",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 600,
"storageRedundancy": "ZoneRedundancy",
"storageSizeGB": 100,
"storageSku": "Premium_ZRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
{
"name": "mysqltestserver",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "cloudsa",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-17T06:11:38.4150019+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 3306,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "mysqltestserver.database.mysql.azure.com",
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3",
"state": "Healthy"
},
"maintenancePolicy": {
"patchStrategy": "Regular"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 10,
"replicationRole": "None",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 600,
"storageRedundancy": "ZoneRedundancy",
"storageSizeGB": 100,
"storageSku": "Premium_ZRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
Create a replica server
Sample request
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/replica-server?api-version=2024-12-30
{
"location": "SoutheastAsia",
"properties": {
"createMode": "Replica",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.mysqlflexibleservers import MySQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-mysqlflexibleservers
# USAGE
python server_create_replica.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 = MySQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create(
resource_group_name="testgr",
server_name="replica-server",
parameters={
"location": "SoutheastAsia",
"properties": {
"createMode": "Replica",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server",
},
},
).result()
print(response)
# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreateReplica.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmysqlflexibleservers_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/mysql/armmysqlflexibleservers/v2"
)
// Generated from example definition: 2024-12-30/ServerCreateReplica.json
func ExampleServersClient_BeginCreate_createAReplicaServer() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmysqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "testgr", "replica-server", armmysqlflexibleservers.Server{
Location: to.Ptr("SoutheastAsia"),
Properties: &armmysqlflexibleservers.ServerProperties{
CreateMode: to.Ptr(armmysqlflexibleservers.CreateModeReplica),
SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server"),
},
}, 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 poll 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 = armmysqlflexibleservers.ServersClientCreateResponse{
// Server: armmysqlflexibleservers.Server{
// Name: to.Ptr("replica-server"),
// Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/replica-server"),
// Location: to.Ptr("Southeast Asia"),
// Properties: &armmysqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AvailabilityZone: to.Ptr("3"),
// Backup: &armmysqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](7),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T08:19:18.5729164+00:00"); return t}()),
// GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
// },
// DatabasePort: to.Ptr[int32](3306),
// FullVersion: to.Ptr("5.7.44"),
// FullyQualifiedDomainName: to.Ptr("replica-server.database.mysql.azure.com"),
// HighAvailability: &armmysqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled),
// State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled),
// },
// MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{
// BatchOfMaintenance: to.Ptr(armmysqlflexibleservers.BatchOfMaintenanceDefault),
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// Network: &armmysqlflexibleservers.Network{
// PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// },
// ReplicaCapacity: to.Ptr[int32](0),
// ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleReplica),
// SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server"),
// State: to.Ptr(armmysqlflexibleservers.ServerStateReady),
// Storage: &armmysqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// Iops: to.Ptr[int32](360),
// StorageRedundancy: to.Ptr(armmysqlflexibleservers.StorageRedundancyEnumLocalRedundancy),
// StorageSizeGB: to.Ptr[int32](20),
// StorageSKU: to.Ptr("Premium_LRS"),
// },
// Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7),
// },
// SKU: &armmysqlflexibleservers.MySQLServerSKU{
// Name: to.Ptr("Standard_D2ds_v4"),
// Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
// },
// Tags: map[string]*string{
// "ElasticServer": to.Ptr("1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.MySql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.MySql.FlexibleServers;
// Generated from example definition: 2024-12-30/ServerCreateReplica.json
// this example is just showing the usage of "Server_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testgr";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this MySqlFlexibleServerResource
MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers();
// invoke the operation
string serverName = "replica-server";
MySqlFlexibleServerData data = new MySqlFlexibleServerData(new AzureLocation("SoutheastAsia"));
ArmOperation<MySqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
MySqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
MySqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "replica-server",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/replica-server",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "cloudsa",
"availabilityZone": "3",
"backup": {
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-24T08:19:18.5729164+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 3306,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "replica-server.database.mysql.azure.com",
"highAvailability": {
"mode": "Disabled",
"state": "NotEnabled"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 0,
"replicationRole": "Replica",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 360,
"storageRedundancy": "LocalRedundancy",
"storageSizeGB": 20,
"storageSku": "Premium_LRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"ElasticServer": "1"
}
}
{
"name": "replica-server",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/replica-server",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "cloudsa",
"availabilityZone": "3",
"backup": {
"backupIntervalHours": 24,
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-24T08:19:18.5729164+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 3306,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "replica-server.database.mysql.azure.com",
"highAvailability": {
"mode": "Disabled",
"state": "NotEnabled"
},
"maintenancePolicy": {
"patchStrategy": "Regular"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 0,
"replicationRole": "Replica",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testgr/providers/Microsoft.DBforMySQL/flexibleServers/source-server",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 360,
"storageRedundancy": "LocalRedundancy",
"storageSizeGB": 20,
"storageSku": "Premium_LRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"ElasticServer": "1"
}
}
Create a server as a point in time restore
Sample request
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TargetResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/targetserver?api-version=2024-12-30
{
"location": "SoutheastAsia",
"properties": {
"createMode": "PointInTimeRestore",
"restorePointInTime": "2021-06-24T00:00:37.467Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/sourceserver"
},
"sku": {
"name": "Standard_D14_v2",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.mysqlflexibleservers import MySQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-mysqlflexibleservers
# USAGE
python server_create_with_point_in_time_restore.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 = MySQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create(
resource_group_name="TargetResourceGroup",
server_name="targetserver",
parameters={
"location": "SoutheastAsia",
"properties": {
"createMode": "PointInTimeRestore",
"restorePointInTime": "2021-06-24T00:00:37.467Z",
"sourceServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/sourceserver",
},
"sku": {"name": "Standard_D14_v2", "tier": "GeneralPurpose"},
"tags": {"num": "1"},
},
).result()
print(response)
# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreateWithPointInTimeRestore.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmysqlflexibleservers_test
import (
"context"
"log"
"time"
"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/mysql/armmysqlflexibleservers/v2"
)
// Generated from example definition: 2024-12-30/ServerCreateWithPointInTimeRestore.json
func ExampleServersClient_BeginCreate_createAServerAsAPointInTimeRestore() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmysqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "TargetResourceGroup", "targetserver", armmysqlflexibleservers.Server{
Location: to.Ptr("SoutheastAsia"),
Properties: &armmysqlflexibleservers.ServerProperties{
CreateMode: to.Ptr(armmysqlflexibleservers.CreateModePointInTimeRestore),
RestorePointInTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T00:00:37.467Z"); return t }()),
SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/sourceserver"),
},
SKU: &armmysqlflexibleservers.MySQLServerSKU{
Name: to.Ptr("Standard_D14_v2"),
Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
},
Tags: map[string]*string{
"num": to.Ptr("1"),
},
}, 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 poll 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 = armmysqlflexibleservers.ServersClientCreateResponse{
// Server: armmysqlflexibleservers.Server{
// Name: to.Ptr("targetserver"),
// Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TargetResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/targetserver"),
// Location: to.Ptr("Southeast Asia"),
// Properties: &armmysqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("adminuser"),
// AvailabilityZone: to.Ptr("1"),
// Backup: &armmysqlflexibleservers.Backup{
// BackupIntervalHours: to.Ptr[int32](24),
// BackupRetentionDays: to.Ptr[int32](7),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-24T00:15:24.00+00:00"); return t}()),
// GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
// },
// DatabasePort: to.Ptr[int32](3306),
// FullVersion: to.Ptr("5.7.44"),
// FullyQualifiedDomainName: to.Ptr("targetserver.database.mysql.azure.com"),
// HighAvailability: &armmysqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeDisabled),
// State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateNotEnabled),
// },
// MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{
// BatchOfMaintenance: to.Ptr(armmysqlflexibleservers.BatchOfMaintenanceDefault),
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// Network: &armmysqlflexibleservers.Network{
// PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// },
// ReplicaCapacity: to.Ptr[int32](10),
// ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone),
// State: to.Ptr(armmysqlflexibleservers.ServerStateReady),
// Storage: &armmysqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// Iops: to.Ptr[int32](360),
// StorageRedundancy: to.Ptr(armmysqlflexibleservers.StorageRedundancyEnumLocalRedundancy),
// StorageSizeGB: to.Ptr[int32](20),
// StorageSKU: to.Ptr("Premium_LRS"),
// },
// Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7),
// },
// SKU: &armmysqlflexibleservers.MySQLServerSKU{
// Name: to.Ptr("Standard_D2ds_v4"),
// Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
// },
// Tags: map[string]*string{
// "num": to.Ptr("1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.MySql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.MySql.FlexibleServers;
// Generated from example definition: 2024-12-30/ServerCreateWithPointInTimeRestore.json
// this example is just showing the usage of "Server_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "TargetResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this MySqlFlexibleServerResource
MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers();
// invoke the operation
string serverName = "targetserver";
MySqlFlexibleServerData data = new MySqlFlexibleServerData(new AzureLocation("SoutheastAsia"))
{
Sku = new MySqlFlexibleServerSku("Standard_D14_v2", MySqlFlexibleServerSkuTier.GeneralPurpose),
Tags =
{
["num"] = "1"
},
};
ArmOperation<MySqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
MySqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
MySqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "targetserver",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TargetResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/targetserver",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "adminuser",
"availabilityZone": "1",
"backup": {
"backupIntervalHours": 24,
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-24T00:15:24.00+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 3306,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "targetserver.database.mysql.azure.com",
"highAvailability": {
"mode": "Disabled",
"state": "NotEnabled"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 10,
"replicationRole": "None",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 360,
"storageRedundancy": "LocalRedundancy",
"storageSizeGB": 20,
"storageSku": "Premium_LRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
{
"name": "targetserver",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TargetResourceGroup/providers/Microsoft.DBforMySQL/flexibleServers/targetserver",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "adminuser",
"availabilityZone": "1",
"backup": {
"backupIntervalHours": 24,
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-24T00:15:24.00+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 3306,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "targetserver.database.mysql.azure.com",
"highAvailability": {
"mode": "Disabled",
"state": "NotEnabled"
},
"maintenancePolicy": {
"patchStrategy": "Regular"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 10,
"replicationRole": "None",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 360,
"storageRedundancy": "LocalRedundancy",
"storageSizeGB": 20,
"storageSku": "Premium_LRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
Create a server with byok
Sample request
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver?api-version=2024-12-30
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {}
}
},
"location": "southeastasia",
"properties": {
"administratorLogin": "cloudsa",
"administratorLoginPassword": "your_password",
"availabilityZone": "1",
"backup": {
"backupIntervalHours": 24,
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"createMode": "Default",
"dataEncryption": {
"type": "AzureKeyVault",
"geoBackupKeyURI": "https://test-geo.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-identity",
"primaryKeyURI": "https://test.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity"
},
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3"
},
"storage": {
"autoGrow": "Disabled",
"iops": 600,
"storageRedundancy": "LocalRedundancy",
"storageSizeGB": 100
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.mysqlflexibleservers import MySQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-mysqlflexibleservers
# USAGE
python server_create_with_byok.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 = MySQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create(
resource_group_name="testrg",
server_name="mysqltestserver",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {}
},
},
"location": "southeastasia",
"properties": {
"administratorLogin": "cloudsa",
"administratorLoginPassword": "your_password",
"availabilityZone": "1",
"backup": {"backupIntervalHours": 24, "backupRetentionDays": 7, "geoRedundantBackup": "Disabled"},
"createMode": "Default",
"dataEncryption": {
"geoBackupKeyURI": "https://test-geo.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a",
"geoBackupUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-identity",
"primaryKeyURI": "https://test.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a",
"primaryUserAssignedIdentityId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity",
"type": "AzureKeyVault",
},
"highAvailability": {"mode": "ZoneRedundant", "standbyAvailabilityZone": "3"},
"storage": {
"autoGrow": "Disabled",
"iops": 600,
"storageRedundancy": "LocalRedundancy",
"storageSizeGB": 100,
},
"version": "5.7",
},
"sku": {"name": "Standard_D2ds_v4", "tier": "GeneralPurpose"},
"tags": {"num": "1"},
},
).result()
print(response)
# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreateWithBYOK.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmysqlflexibleservers_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/mysql/armmysqlflexibleservers/v2"
)
// Generated from example definition: 2024-12-30/ServerCreateWithBYOK.json
func ExampleServersClient_BeginCreate_createAServerWithByok() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmysqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.Server{
Identity: &armmysqlflexibleservers.MySQLServerIdentity{
Type: to.Ptr(armmysqlflexibleservers.ManagedServiceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armmysqlflexibleservers.UserAssignedIdentity{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {},
},
},
Location: to.Ptr("southeastasia"),
Properties: &armmysqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("cloudsa"),
AdministratorLoginPassword: to.Ptr("your_password"),
AvailabilityZone: to.Ptr("1"),
Backup: &armmysqlflexibleservers.Backup{
BackupIntervalHours: to.Ptr[int32](24),
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
},
CreateMode: to.Ptr(armmysqlflexibleservers.CreateModeDefault),
DataEncryption: &armmysqlflexibleservers.DataEncryption{
Type: to.Ptr(armmysqlflexibleservers.DataEncryptionTypeAzureKeyVault),
GeoBackupKeyURI: to.Ptr("https://test-geo.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"),
GeoBackupUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-identity"),
PrimaryKeyURI: to.Ptr("https://test.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"),
PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity"),
},
HighAvailability: &armmysqlflexibleservers.HighAvailability{
Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant),
StandbyAvailabilityZone: to.Ptr("3"),
},
Storage: &armmysqlflexibleservers.Storage{
AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
Iops: to.Ptr[int32](600),
StorageRedundancy: to.Ptr(armmysqlflexibleservers.StorageRedundancyEnumLocalRedundancy),
StorageSizeGB: to.Ptr[int32](100),
},
Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7),
},
SKU: &armmysqlflexibleservers.MySQLServerSKU{
Name: to.Ptr("Standard_D2ds_v4"),
Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
},
Tags: map[string]*string{
"num": to.Ptr("1"),
},
}, 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 poll 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 = armmysqlflexibleservers.ServersClientCreateResponse{
// Server: armmysqlflexibleservers.Server{
// Name: to.Ptr("mysqltestserver"),
// Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"),
// Location: to.Ptr("Southeast Asia"),
// Properties: &armmysqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AvailabilityZone: to.Ptr("1"),
// Backup: &armmysqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](7),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()),
// GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
// },
// DatabasePort: to.Ptr[int32](3306),
// FullVersion: to.Ptr("5.7.44"),
// FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"),
// HighAvailability: &armmysqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("3"),
// State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateHealthy),
// },
// MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{
// BatchOfMaintenance: to.Ptr(armmysqlflexibleservers.BatchOfMaintenanceDefault),
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// Network: &armmysqlflexibleservers.Network{
// PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// },
// ReplicaCapacity: to.Ptr[int32](10),
// ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone),
// State: to.Ptr(armmysqlflexibleservers.ServerStateReady),
// Storage: &armmysqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// Iops: to.Ptr[int32](600),
// StorageRedundancy: to.Ptr(armmysqlflexibleservers.StorageRedundancyEnumZoneRedundancy),
// StorageSizeGB: to.Ptr[int32](100),
// StorageSKU: to.Ptr("Premium_ZRS"),
// },
// Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7),
// },
// SKU: &armmysqlflexibleservers.MySQLServerSKU{
// Name: to.Ptr("Standard_D2ds_v4"),
// Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
// },
// Tags: map[string]*string{
// "num": to.Ptr("1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.MySql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.MySql.FlexibleServers;
// Generated from example definition: 2024-12-30/ServerCreateWithBYOK.json
// this example is just showing the usage of "Server_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testrg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this MySqlFlexibleServerResource
MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers();
// invoke the operation
string serverName = "mysqltestserver";
MySqlFlexibleServerData data = new MySqlFlexibleServerData(new AzureLocation("southeastasia"))
{
Identity = new ManagedServiceIdentity("UserAssigned")
{
UserAssignedIdentities =
{
[new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity()
},
},
Sku = new MySqlFlexibleServerSku("Standard_D2ds_v4", MySqlFlexibleServerSkuTier.GeneralPurpose),
Tags =
{
["num"] = "1"
},
};
ArmOperation<MySqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
MySqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
MySqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "mysqltestserver",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "cloudsa",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-17T06:11:38.4150019+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 3306,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "mysqltestserver.database.mysql.azure.com",
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3",
"state": "Healthy"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 10,
"replicationRole": "None",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 600,
"storageRedundancy": "ZoneRedundancy",
"storageSizeGB": 100,
"storageSku": "Premium_ZRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
{
"name": "mysqltestserver",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "cloudsa",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-17T06:11:38.4150019+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 3306,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "mysqltestserver.database.mysql.azure.com",
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3",
"state": "Healthy"
},
"maintenancePolicy": {
"patchStrategy": "Regular"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 10,
"replicationRole": "None",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 600,
"storageRedundancy": "ZoneRedundancy",
"storageSizeGB": 100,
"storageSku": "Premium_ZRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
Create a server with non-default database port
Sample request
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver?api-version=2024-12-30
{
"location": "southeastasia",
"properties": {
"administratorLogin": "cloudsa",
"administratorLoginPassword": "your_password",
"availabilityZone": "1",
"backup": {
"backupIntervalHours": 24,
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"createMode": "Default",
"databasePort": 8888,
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3"
},
"storage": {
"autoGrow": "Disabled",
"iops": 600,
"storageRedundancy": "LocalRedundancy",
"storageSizeGB": 100
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.mysqlflexibleservers import MySQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-mysqlflexibleservers
# USAGE
python server_create_with_database_port.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 = MySQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.servers.begin_create(
resource_group_name="testrg",
server_name="mysqltestserver",
parameters={
"location": "southeastasia",
"properties": {
"administratorLogin": "cloudsa",
"administratorLoginPassword": "your_password",
"availabilityZone": "1",
"backup": {"backupIntervalHours": 24, "backupRetentionDays": 7, "geoRedundantBackup": "Disabled"},
"createMode": "Default",
"databasePort": 8888,
"highAvailability": {"mode": "ZoneRedundant", "standbyAvailabilityZone": "3"},
"storage": {
"autoGrow": "Disabled",
"iops": 600,
"storageRedundancy": "LocalRedundancy",
"storageSizeGB": 100,
},
"version": "5.7",
},
"sku": {"name": "Standard_D2ds_v4", "tier": "GeneralPurpose"},
"tags": {"num": "1"},
},
).result()
print(response)
# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreateWithDatabasePort.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmysqlflexibleservers_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/mysql/armmysqlflexibleservers/v2"
)
// Generated from example definition: 2024-12-30/ServerCreateWithDatabasePort.json
func ExampleServersClient_BeginCreate_createAServerWithNonDefaultDatabasePort() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmysqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewServersClient().BeginCreate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.Server{
Location: to.Ptr("southeastasia"),
Properties: &armmysqlflexibleservers.ServerProperties{
AdministratorLogin: to.Ptr("cloudsa"),
AdministratorLoginPassword: to.Ptr("your_password"),
AvailabilityZone: to.Ptr("1"),
Backup: &armmysqlflexibleservers.Backup{
BackupIntervalHours: to.Ptr[int32](24),
BackupRetentionDays: to.Ptr[int32](7),
GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
},
CreateMode: to.Ptr(armmysqlflexibleservers.CreateModeDefault),
DatabasePort: to.Ptr[int32](8888),
HighAvailability: &armmysqlflexibleservers.HighAvailability{
Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant),
StandbyAvailabilityZone: to.Ptr("3"),
},
Storage: &armmysqlflexibleservers.Storage{
AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
Iops: to.Ptr[int32](600),
StorageRedundancy: to.Ptr(armmysqlflexibleservers.StorageRedundancyEnumLocalRedundancy),
StorageSizeGB: to.Ptr[int32](100),
},
Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7),
},
SKU: &armmysqlflexibleservers.MySQLServerSKU{
Name: to.Ptr("Standard_D2ds_v4"),
Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
},
Tags: map[string]*string{
"num": to.Ptr("1"),
},
}, 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 poll 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 = armmysqlflexibleservers.ServersClientCreateResponse{
// Server: armmysqlflexibleservers.Server{
// Name: to.Ptr("mysqltestserver"),
// Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"),
// ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver"),
// Location: to.Ptr("Southeast Asia"),
// Properties: &armmysqlflexibleservers.ServerProperties{
// AdministratorLogin: to.Ptr("cloudsa"),
// AvailabilityZone: to.Ptr("1"),
// Backup: &armmysqlflexibleservers.Backup{
// BackupRetentionDays: to.Ptr[int32](7),
// EarliestRestoreDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T06:11:38.4150019+00:00"); return t}()),
// GeoRedundantBackup: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled),
// },
// DatabasePort: to.Ptr[int32](8888),
// FullVersion: to.Ptr("5.7.44"),
// FullyQualifiedDomainName: to.Ptr("mysqltestserver.database.mysql.azure.com"),
// HighAvailability: &armmysqlflexibleservers.HighAvailability{
// Mode: to.Ptr(armmysqlflexibleservers.HighAvailabilityModeZoneRedundant),
// StandbyAvailabilityZone: to.Ptr("3"),
// State: to.Ptr(armmysqlflexibleservers.HighAvailabilityStateHealthy),
// },
// MaintenanceWindow: &armmysqlflexibleservers.MaintenanceWindow{
// BatchOfMaintenance: to.Ptr(armmysqlflexibleservers.BatchOfMaintenanceDefault),
// CustomWindow: to.Ptr("Disabled"),
// DayOfWeek: to.Ptr[int32](0),
// StartHour: to.Ptr[int32](0),
// StartMinute: to.Ptr[int32](0),
// },
// Network: &armmysqlflexibleservers.Network{
// PublicNetworkAccess: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// },
// ReplicaCapacity: to.Ptr[int32](10),
// ReplicationRole: to.Ptr(armmysqlflexibleservers.ReplicationRoleNone),
// State: to.Ptr(armmysqlflexibleservers.ServerStateReady),
// Storage: &armmysqlflexibleservers.Storage{
// AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled),
// Iops: to.Ptr[int32](600),
// StorageRedundancy: to.Ptr(armmysqlflexibleservers.StorageRedundancyEnumZoneRedundancy),
// StorageSizeGB: to.Ptr[int32](100),
// StorageSKU: to.Ptr("Premium_ZRS"),
// },
// Version: to.Ptr(armmysqlflexibleservers.ServerVersionFive7),
// },
// SKU: &armmysqlflexibleservers.MySQLServerSKU{
// Name: to.Ptr("Standard_D2ds_v4"),
// Tier: to.Ptr(armmysqlflexibleservers.ServerSKUTierGeneralPurpose),
// },
// Tags: map[string]*string{
// "num": to.Ptr("1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.MySql.FlexibleServers.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.MySql.FlexibleServers;
// Generated from example definition: 2024-12-30/ServerCreateWithDatabasePort.json
// this example is just showing the usage of "Server_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "testrg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this MySqlFlexibleServerResource
MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers();
// invoke the operation
string serverName = "mysqltestserver";
MySqlFlexibleServerData data = new MySqlFlexibleServerData(new AzureLocation("southeastasia"))
{
Sku = new MySqlFlexibleServerSku("Standard_D2ds_v4", MySqlFlexibleServerSkuTier.GeneralPurpose),
Tags =
{
["num"] = "1"
},
};
ArmOperation<MySqlFlexibleServerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data);
MySqlFlexibleServerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
MySqlFlexibleServerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "mysqltestserver",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "cloudsa",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-17T06:11:38.4150019+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 8888,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "mysqltestserver.database.mysql.azure.com",
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3",
"state": "Healthy"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 10,
"replicationRole": "None",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 600,
"storageRedundancy": "ZoneRedundancy",
"storageSizeGB": 100,
"storageSku": "Premium_ZRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
{
"name": "mysqltestserver",
"type": "Microsoft.DBforMySQL/flexibleServers",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver",
"location": "Southeast Asia",
"properties": {
"administratorLogin": "cloudsa",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"earliestRestoreDate": "2021-06-17T06:11:38.4150019+00:00",
"geoRedundantBackup": "Disabled"
},
"databasePort": 8888,
"fullVersion": "5.7.44",
"fullyQualifiedDomainName": "mysqltestserver.database.mysql.azure.com",
"highAvailability": {
"mode": "ZoneRedundant",
"standbyAvailabilityZone": "3",
"state": "Healthy"
},
"maintenanceWindow": {
"batchOfMaintenance": "Default",
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"network": {
"publicNetworkAccess": "Enabled"
},
"replicaCapacity": 10,
"replicationRole": "None",
"state": "Ready",
"storage": {
"autoGrow": "Enabled",
"iops": 600,
"storageRedundancy": "ZoneRedundancy",
"storageSizeGB": 100,
"storageSku": "Premium_ZRS"
},
"version": "5.7"
},
"sku": {
"name": "Standard_D2ds_v4",
"tier": "GeneralPurpose"
},
"tags": {
"num": "1"
}
}
Definitions
Backup
Object
Storage Profile properties of a server
| Name |
Type |
Default value |
Description |
|
backupIntervalHours
|
integer
(int32)
|
|
Backup interval hours for the server.
|
|
backupRetentionDays
|
integer
(int32)
|
|
Backup retention days for the server.
|
|
earliestRestoreDate
|
string
(date-time)
|
|
Earliest restore point creation time (ISO8601 format)
|
|
geoRedundantBackup
|
EnableStatusEnum
|
Disabled
|
Whether or not geo redundant backup is enabled.
|
BatchOfMaintenance
Enumeration
The batch of maintenance when enabled the custom managed maintenance window of a server.
| Value |
Description |
|
Default
|
|
|
Batch1
|
|
|
Batch2
|
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
CreateMode
Enumeration
The mode to create a new MySQL server.
| Value |
Description |
|
Default
|
|
|
PointInTimeRestore
|
|
|
Replica
|
|
|
GeoRestore
|
|
DataEncryption
Object
The date encryption for cmk.
| Name |
Type |
Description |
|
geoBackupKeyURI
|
string
|
Geo backup key uri as key vault can't cross region, need cmk in same region as geo backup
|
|
geoBackupUserAssignedIdentityId
|
string
|
Geo backup user identity resource id as identity can't cross region, need identity in same region as geo backup
|
|
primaryKeyURI
|
string
|
Primary key uri
|
|
primaryUserAssignedIdentityId
|
string
|
Primary user identity resource id
|
|
type
|
DataEncryptionType
|
The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk.
|
DataEncryptionType
Enumeration
The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk.
| Value |
Description |
|
AzureKeyVault
|
|
|
SystemManaged
|
|
EnableStatusEnum
Enumeration
Enum to indicate whether value is 'Enabled' or 'Disabled'
| Value |
Description |
|
Enabled
|
|
|
Disabled
|
|
ErrorAdditionalInfo
Object
The resource management error additional info.
| Name |
Type |
Description |
|
info
|
object
|
The additional info.
|
|
type
|
string
|
The additional info type.
|
ErrorDetail
Object
The error detail.
| Name |
Type |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
|
code
|
string
|
The error code.
|
|
details
|
ErrorDetail[]
|
The error details.
|
|
message
|
string
|
The error message.
|
|
target
|
string
|
The error target.
|
ErrorResponse
Object
Error response
| Name |
Type |
Description |
|
error
|
ErrorDetail
|
The error object.
|
HighAvailability
Object
High availability properties of a server
| Name |
Type |
Description |
|
mode
|
HighAvailabilityMode
|
High availability mode for a server.
|
|
standbyAvailabilityZone
|
string
|
Availability zone of the standby server.
|
|
state
|
HighAvailabilityState
|
The state of server high availability.
|
HighAvailabilityMode
Enumeration
High availability mode for a server.
| Value |
Description |
|
Disabled
|
|
|
ZoneRedundant
|
|
|
SameZone
|
|
HighAvailabilityState
Enumeration
The state of server high availability.
| Value |
Description |
|
NotEnabled
|
|
|
CreatingStandby
|
|
|
Healthy
|
|
|
FailingOver
|
|
|
RemovingStandby
|
|
ImportSourceProperties
Object
Import source related properties.
| Name |
Type |
Description |
|
dataDirPath
|
string
|
Relative path of data directory in storage.
|
|
sasToken
|
string
(password)
|
Sas token for accessing source storage. Read and list permissions are required for sas token.
|
|
storageType
|
ImportSourceStorageType
|
Storage type of import source.
|
|
storageUrl
|
string
|
Uri of the import source storage.
|
ImportSourceStorageType
Enumeration
Storage type of import source.
| Value |
Description |
|
AzureBlob
|
|
MaintenancePolicy
Object
Maintenance policy of a server.
| Name |
Type |
Description |
|
patchStrategy
|
PatchStrategy
|
The patch strategy of this server
|
MaintenanceWindow
Object
Maintenance window of a server.
| Name |
Type |
Description |
|
batchOfMaintenance
|
BatchOfMaintenance
|
The batch of maintenance when enabled the custom managed maintenance window of a server.
|
|
customWindow
|
string
|
indicates whether custom window is enabled or disabled
|
|
dayOfWeek
|
integer
(int32)
|
day of week for maintenance window
|
|
startHour
|
integer
(int32)
|
start hour for maintenance window
|
|
startMinute
|
integer
(int32)
|
start minute for maintenance window
|
ManagedServiceIdentityType
Enumeration
Type of managed service identity.
| Value |
Description |
|
UserAssigned
|
|
MySQLServerIdentity
Object
Properties to configure Identity for Bring your Own Keys
| Name |
Type |
Description |
|
principalId
|
string
|
ObjectId from the KeyVault
|
|
tenantId
|
string
|
TenantId from the KeyVault
|
|
type
|
ManagedServiceIdentityType
|
Type of managed service identity.
|
|
userAssignedIdentities
|
<string,
UserAssignedIdentity>
|
Metadata of user assigned identity.
|
MySQLServerSku
Object
Billing information related properties of a server.
| Name |
Type |
Description |
|
name
|
string
|
The name of the sku, e.g. Standard_D32s_v3.
|
|
tier
|
ServerSkuTier
|
The tier of the particular SKU, e.g. GeneralPurpose.
|
Network
Object
Network related properties of a server
| Name |
Type |
Description |
|
delegatedSubnetResourceId
|
string
|
Delegated subnet resource id used to setup vnet for a server.
|
|
privateDnsZoneResourceId
|
string
|
Private DNS zone resource id.
|
|
publicNetworkAccess
|
EnableStatusEnum
|
Whether or not public network access is allowed for this server. Value is 'Disabled' when server has VNet integration.
|
PatchStrategy
Enumeration
Enum to indicate the patch strategy of a server
| Value |
Description |
|
Regular
|
|
|
VirtualCanary
|
|
PrivateEndpoint
Object
The private endpoint resource.
| Name |
Type |
Description |
|
id
|
string
|
The ARM identifier for private endpoint.
|
PrivateEndpointConnection
Object
The private endpoint connection resource.
| Name |
Type |
Description |
|
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
name
|
string
|
The name of the resource
|
|
properties.groupIds
|
string[]
|
The group ids for the private endpoint resource.
|
|
properties.privateEndpoint
|
PrivateEndpoint
|
The private endpoint resource.
|
|
properties.privateLinkServiceConnectionState
|
PrivateLinkServiceConnectionState
|
A collection of information about the state of the connection between service consumer and provider.
|
|
properties.provisioningState
|
PrivateEndpointConnectionProvisioningState
|
The provisioning state of the private endpoint connection resource.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
PrivateEndpointConnectionProvisioningState
Enumeration
The current provisioning state.
| Value |
Description |
|
Succeeded
|
|
|
Creating
|
|
|
Deleting
|
|
|
Failed
|
|
PrivateEndpointServiceConnectionStatus
Enumeration
The private endpoint connection status.
| Value |
Description |
|
Pending
|
|
|
Approved
|
|
|
Rejected
|
|
PrivateLinkServiceConnectionState
Object
A collection of information about the state of the connection between service consumer and provider.
| Name |
Type |
Description |
|
actionsRequired
|
string
|
A message indicating if changes on the service provider require any updates on the consumer.
|
|
description
|
string
|
The reason for approval/rejection of the connection.
|
|
status
|
PrivateEndpointServiceConnectionStatus
|
Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.
|
ReplicationRole
Enumeration
The replication role.
| Value |
Description |
|
None
|
|
|
Source
|
|
|
Replica
|
|
Server
Object
Represents a server.
| Name |
Type |
Description |
|
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
MySQLServerIdentity
|
The cmk identity for the server.
|
|
location
|
string
|
The geo-location where the resource lives
|
|
name
|
string
|
The name of the resource
|
|
properties.administratorLogin
|
string
|
The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation).
|
|
properties.administratorLoginPassword
|
string
(password)
|
The password of the administrator login (required for server creation).
|
|
properties.availabilityZone
|
string
|
availability Zone information of the server.
|
|
properties.backup
|
Backup
|
Backup related properties of a server.
|
|
properties.createMode
|
CreateMode
|
The mode to create a new MySQL server.
|
|
properties.dataEncryption
|
DataEncryption
|
The Data Encryption for CMK.
|
|
properties.databasePort
|
integer
(int32)
|
The server database port. Can only be specified when the server is being created.
|
|
properties.fullVersion
|
string
|
Major version and actual engine version
|
|
properties.fullyQualifiedDomainName
|
string
|
The fully qualified domain name of a server.
|
|
properties.highAvailability
|
HighAvailability
|
High availability related properties of a server.
|
|
properties.importSourceProperties
|
ImportSourceProperties
|
Source properties for import from storage.
|
|
properties.maintenancePolicy
|
MaintenancePolicy
|
Maintenance policy of a server.
|
|
properties.maintenanceWindow
|
MaintenanceWindow
|
Maintenance window of a server. Known issue: cannot be set during server creation or updated with other properties during server update; must be updated separately.
|
|
properties.network
|
Network
|
Network related properties of a server.
|
|
properties.privateEndpointConnections
|
PrivateEndpointConnection[]
|
PrivateEndpointConnections related properties of a server.
|
|
properties.replicaCapacity
|
integer
(int32)
minimum: 0
|
The maximum number of replicas that a primary server can have.
|
|
properties.replicationRole
|
ReplicationRole
|
The replication role.
|
|
properties.restorePointInTime
|
string
(date-time)
|
Restore point creation time (ISO8601 format), specifying the time to restore from.
|
|
properties.sourceServerResourceId
|
string
|
The source MySQL server id.
|
|
properties.state
|
ServerState
|
The state of a server.
|
|
properties.storage
|
Storage
|
Storage related properties of a server.
|
|
properties.version
|
ServerVersion
|
Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL 5.7
|
|
sku
|
MySQLServerSku
|
The SKU (pricing tier) of the server.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
tags
|
object
|
Resource tags.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
ServerSkuTier
Enumeration
The tier of the particular SKU, e.g. GeneralPurpose.
| Value |
Description |
|
Burstable
|
|
|
GeneralPurpose
|
|
|
MemoryOptimized
|
|
ServerState
Enumeration
The state of a server.
| Value |
Description |
|
Ready
|
|
|
Dropping
|
|
|
Disabled
|
|
|
Starting
|
|
|
Stopping
|
|
|
Stopped
|
|
|
Updating
|
|
ServerVersion
Enumeration
The major version of a server. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL 5.7
| Value |
Description |
|
5.7
|
|
|
8.0.21
|
|
Storage
Object
Storage Profile properties of a server
| Name |
Type |
Default value |
Description |
|
autoGrow
|
EnableStatusEnum
|
Disabled
|
Enable Storage Auto Grow or not.
|
|
autoIoScaling
|
EnableStatusEnum
|
Enabled
|
Enable IO Auto Scaling or not.
|
|
iops
|
integer
(int32)
|
|
Storage IOPS for a server.
|
|
logOnDisk
|
EnableStatusEnum
|
Disabled
|
Enable Log On Disk or not.
|
|
storageRedundancy
|
StorageRedundancyEnum
|
LocalRedundancy
|
The redundant type of the server storage. The parameter is used for server creation.
|
|
storageSizeGB
|
integer
(int32)
|
|
Max storage size allowed for a server.
|
|
storageSku
|
string
|
|
The sku name of the server storage.
|
StorageRedundancyEnum
Enumeration
The redundant type of the server storage. The parameter is used for server creation.
| Value |
Description |
|
LocalRedundancy
|
|
|
ZoneRedundancy
|
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|
UserAssignedIdentity
Object
Metadata of user assigned identity.
| Name |
Type |
Description |
|
clientId
|
string
|
Client Id of user assigned identity
|
|
principalId
|
string
|
Principal Id of user assigned identity
|