Skip to main content Skills Marketplace Discover and explore AI skills built by the community.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Copy promptShow prompt details A direct command skips the review prompt. Inspect the source before running it.
npx skills add https://github.com/christophacham/agent-skills-library --skill azure-resource-manager-mysql-dotnetThe command stays on one line. Scroll horizontally to inspect it before copying.
Prefer a local copy? Download the files currently available to SkillsMP.
Download Zip Downloading... More from this repository Expert service mesh architect specializing in Istio, Linkerd, and cloud-native networking patterns. Masters traffic management, security policies, observability integration, and multi-cluster mesh con
service-mesh-observability Implement comprehensive observability for service meshes including distributed tracing, metrics, and visualization. Use when setting up mesh monitoring, debugging latency issues, or implementing SL...
Expert guide for writing efficient GLSL shaders (Vertex/Fragment) for web and game engines, covering syntax, uniforms, and common effects.
Related occupations SOC
Based on SOC occupation classification
name azure-resource-manager-mysql-dotnet description Azure MySQL Flexible Server SDK for .NET. Database management for MySQL Flexible Server deployments. risk unknown source community date_added 2026-02-27
Azure.ResourceManager.MySql (.NET)
Azure Resource Manager SDK for managing MySQL Flexible Server deployments.
Installation
dotnet add package Azure.ResourceManager.MySql
dotnet add package Azure.Identity
Current Version : v1.2.0 (GA)
API Version : 2023-12-30
Note : This skill focuses on MySQL Flexible Server. Single Server is deprecated and scheduled for retirement.
Environment Variables
AZURE_SUBSCRIPTION_ID=<your-subscription-id>
AZURE_RESOURCE_GROUP=<your-resource-group>
AZURE_MYSQL_SERVER_NAME=<your-mysql-server>
Authentication
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.MySql;
Azure.ResourceManager.MySql.FlexibleServers;
ArmClient client = ArmClient( DefaultAzureCredential());
using
new
new
Resource Hierarchy Subscription
└── ResourceGroup
└── MySqlFlexibleServer # MySQL Flexible Server instance
├── MySqlFlexibleServerDatabase # Database within the server
├── MySqlFlexibleServerFirewallRule # IP firewall rules
├── MySqlFlexibleServerConfiguration # Server parameters
├── MySqlFlexibleServerBackup # Backup information
├── MySqlFlexibleServerMaintenanceWindow # Maintenance schedule
└── MySqlFlexibleServerAadAdministrator # Entra ID admin
Core Workflows
1. Create MySQL Flexible Server using Azure.ResourceManager.MySql.FlexibleServers;
using Azure.ResourceManager.MySql.FlexibleServers.Models;
ResourceGroupResource resourceGroup = await client
.GetDefaultSubscriptionAsync()
.Result
.GetResourceGroupAsync("my-resource-group" );
MySqlFlexibleServerCollection servers = resourceGroup.GetMySqlFlexibleServers();
MySqlFlexibleServerData data = new MySqlFlexibleServerData(AzureLocation.EastUS)
{
Sku = new MySqlFlexibleServerSku("Standard_D2ds_v4" , MySqlFlexibleServerSkuTier.GeneralPurpose),
AdministratorLogin = "mysqladmin" ,
AdministratorLoginPassword = "YourSecurePassword123!" ,
Version = MySqlFlexibleServerVersion.Ver8_0_21,
Storage = new MySqlFlexibleServerStorage
{
StorageSizeInGB = 128 ,
AutoGrow = MySqlFlexibleServerEnableStatusEnum.Enabled,
Iops = 3000
},
Backup = new MySqlFlexibleServerBackupProperties
{
BackupRetentionDays = 7 ,
GeoRedundantBackup = MySqlFlexibleServerEnableStatusEnum.Disabled
},
HighAvailability = new MySqlFlexibleServerHighAvailability
{
Mode = MySqlFlexibleServerHighAvailabilityMode.ZoneRedundant,
StandbyAvailabilityZone = "2"
},
AvailabilityZone = "1"
};
ArmOperation<MySqlFlexibleServerResource> operation = await servers
.CreateOrUpdateAsync(WaitUntil.Completed, "my-mysql-server" , data);
MySqlFlexibleServerResource server = operation.Value;
Console.WriteLine($"Server created: {server.Data.FullyQualifiedDomainName} " );
2. Create Database MySqlFlexibleServerResource server = await resourceGroup
.GetMySqlFlexibleServerAsync("my-mysql-server" );
MySqlFlexibleServerDatabaseCollection databases = server.GetMySqlFlexibleServerDatabases();
MySqlFlexibleServerDatabaseData dbData = new MySqlFlexibleServerDatabaseData
{
Charset = "utf8mb4" ,
Collation = "utf8mb4_unicode_ci"
};
ArmOperation<MySqlFlexibleServerDatabaseResource> operation = await databases
.CreateOrUpdateAsync(WaitUntil.Completed, "myappdb" , dbData);
MySqlFlexibleServerDatabaseResource database = operation.Value;
Console.WriteLine($"Database created: {database.Data.Name} " );
3. Configure Firewall Rules MySqlFlexibleServerFirewallRuleCollection firewallRules = server.GetMySqlFlexibleServerFirewallRules();
MySqlFlexibleServerFirewallRuleData ruleData = new MySqlFlexibleServerFirewallRuleData
{
StartIPAddress = System.Net.IPAddress.Parse("10.0.0.1" ),
EndIPAddress = System.Net.IPAddress.Parse("10.0.0.255" )
};
ArmOperation<MySqlFlexibleServerFirewallRuleResource> operation = await firewallRules
.CreateOrUpdateAsync(WaitUntil.Completed, "allow-internal" , ruleData);
MySqlFlexibleServerFirewallRuleData azureServicesRule = new MySqlFlexibleServerFirewallRuleData
{
StartIPAddress = System.Net.IPAddress.Parse("0.0.0.0" ),
EndIPAddress = System.Net.IPAddress.Parse("0.0.0.0" )
};
await firewallRules.CreateOrUpdateAsync(WaitUntil.Completed, "AllowAllAzureServicesAndResourcesWithinAzureIps" , azureServicesRule);
4. Update Server Configuration MySqlFlexibleServerConfigurationCollection configurations = server.GetMySqlFlexibleServerConfigurations();
MySqlFlexibleServerConfigurationResource config = await configurations
.GetAsync("max_connections" );
MySqlFlexibleServerConfigurationData configData = new MySqlFlexibleServerConfigurationData
{
Value = "500" ,
Source = MySqlFlexibleServerConfigurationSource.UserOverride
};
ArmOperation<MySqlFlexibleServerConfigurationResource> operation = await configurations
.CreateOrUpdateAsync(WaitUntil.Completed, "max_connections" , configData);
string [] commonParams = { "max_connections" , "innodb_buffer_pool_size" , "slow_query_log" , "long_query_time" };
5. Configure Entra ID Administrator MySqlFlexibleServerAadAdministratorCollection admins = server.GetMySqlFlexibleServerAadAdministrators();
MySqlFlexibleServerAadAdministratorData adminData = new MySqlFlexibleServerAadAdministratorData
{
AdministratorType = MySqlFlexibleServerAdministratorType.ActiveDirectory,
Login = "aad-admin@contoso.com" ,
Sid = Guid.Parse("<entra-object-id>" ),
TenantId = Guid.Parse("<tenant-id>" ),
IdentityResourceId = new ResourceIdentifier("/subscriptions/.../userAssignedIdentities/mysql-identity" )
};
ArmOperation<MySqlFlexibleServerAadAdministratorResource> operation = await admins
.CreateOrUpdateAsync(WaitUntil.Completed, "ActiveDirectory" , adminData);
6. List and Manage Servers
await foreach (MySqlFlexibleServerResource server in resourceGroup.GetMySqlFlexibleServers())
{
Console.WriteLine($"Server: {server.Data.Name} " );
Console.WriteLine($" FQDN: {server.Data.FullyQualifiedDomainName} " );
Console.WriteLine($" Version: {server.Data.Version} " );
Console.WriteLine($" State: {server.Data.State} " );
Console.WriteLine($" SKU: {server.Data.Sku.Name} ({server.Data.Sku.Tier} )" );
}
await foreach (MySqlFlexibleServerDatabaseResource db in server.GetMySqlFlexibleServerDatabases())
{
Console.WriteLine($"Database: {db.Data.Name} " );
}
7. Backup and Restore
await foreach (MySqlFlexibleServerBackupResource backup in server.GetMySqlFlexibleServerBackups())
{
Console.WriteLine($"Backup: {backup.Data.Name} " );
Console.WriteLine($" Type: {backup.Data.BackupType} " );
Console.WriteLine($" Completed: {backup.Data.CompletedOn} " );
}
MySqlFlexibleServerData restoreData = new MySqlFlexibleServerData(AzureLocation.EastUS)
{
CreateMode = MySqlFlexibleServerCreateMode.PointInTimeRestore,
SourceServerResourceId = server.Id,
RestorePointInTime = DateTimeOffset.UtcNow.AddHours(-2 )
};
ArmOperation<MySqlFlexibleServerResource> operation = await servers
.CreateOrUpdateAsync(WaitUntil.Completed, "my-mysql-restored" , restoreData);
8. Stop and Start Server MySqlFlexibleServerResource server = await resourceGroup
.GetMySqlFlexibleServerAsync("my-mysql-server" );
await server.StopAsync(WaitUntil.Completed);
await server.StartAsync(WaitUntil.Completed);
await server.RestartAsync(WaitUntil.Completed, new MySqlFlexibleServerRestartParameter
{
RestartWithFailover = MySqlFlexibleServerEnableStatusEnum.Enabled,
MaxFailoverSeconds = 60
});
9. Update Server (Scale) MySqlFlexibleServerResource server = await resourceGroup
.GetMySqlFlexibleServerAsync("my-mysql-server" );
MySqlFlexibleServerPatch patch = new MySqlFlexibleServerPatch
{
Sku = new MySqlFlexibleServerSku("Standard_D4ds_v4" , MySqlFlexibleServerSkuTier.GeneralPurpose),
Storage = new MySqlFlexibleServerStorage
{
StorageSizeInGB = 256 ,
Iops = 6000
}
};
ArmOperation<MySqlFlexibleServerResource> operation = await server
.UpdateAsync(WaitUntil.Completed, patch);
10. Delete Server MySqlFlexibleServerResource server = await resourceGroup
.GetMySqlFlexibleServerAsync("my-mysql-server" );
await server.DeleteAsync(WaitUntil.Completed);
Key Types Reference Type Purpose MySqlFlexibleServerResourceFlexible Server instance MySqlFlexibleServerDataServer configuration data MySqlFlexibleServerCollectionCollection of servers MySqlFlexibleServerDatabaseResourceDatabase within server MySqlFlexibleServerFirewallRuleResourceIP firewall rule MySqlFlexibleServerConfigurationResourceServer parameter MySqlFlexibleServerBackupResourceBackup metadata MySqlFlexibleServerAadAdministratorResourceEntra ID admin MySqlFlexibleServerSkuSKU (compute tier + size) MySqlFlexibleServerStorageStorage configuration MySqlFlexibleServerHighAvailabilityHA configuration MySqlFlexibleServerBackupPropertiesBackup settings
SKU Tiers Tier Use Case SKU Examples BurstableDev/test, light workloads Standard_B1ms, Standard_B2s GeneralPurposeProduction workloads Standard_D2ds_v4, Standard_D4ds_v4 MemoryOptimizedHigh memory requirements Standard_E2ds_v4, Standard_E4ds_v4
High Availability Modes Mode Description DisabledNo HA (single server) SameZoneHA within same availability zone ZoneRedundantHA across availability zones
Best Practices
Use Flexible Server — Single Server is deprecated
Enable zone-redundant HA — For production workloads
Use DefaultAzureCredential — Prefer over connection strings
Configure Entra ID authentication — More secure than SQL auth
Enable auto-grow storage — Prevents out-of-space issues
Set appropriate backup retention — 7-35 days based on compliance
Use private endpoints — For secure network access
Tune server parameters — Based on workload characteristics
Monitor with Azure Monitor — Enable metrics and logs
Stop dev/test servers — Save costs when not in use
Error Handling using Azure;
try
{
ArmOperation<MySqlFlexibleServerResource> operation = await servers
.CreateOrUpdateAsync(WaitUntil.Completed, "my-mysql" , data);
}
catch (RequestFailedException ex) when (ex.Status == 409 )
{
Console.WriteLine("Server already exists" );
}
catch (RequestFailedException ex) when (ex.Status == 400 )
{
Console.WriteLine($"Invalid configuration: {ex.Message} " );
}
catch (RequestFailedException ex)
{
Console.WriteLine($"Azure error: {ex.Status} - {ex.Message} " );
}
Connection String After creating the server, connect using:
string connectionString = $"Server={server.Data.FullyQualifiedDomainName} ;" +
"Database=myappdb;" +
"User Id=mysqladmin;" +
"Password=YourSecurePassword123!;" +
"SslMode=Required;" ;
var credential = new DefaultAzureCredential();
var token = await credential.GetTokenAsync(
new TokenRequestContext(new [] { "https://ossrdbms-aad.database.windows.net/.default" }));
string connectionString = $"Server={server.Data.FullyQualifiedDomainName} ;" +
"Database=myappdb;" +
$"User Id=aad-admin@contoso.com;" +
$"Password={token.Token} ;" +
"SslMode=Required;" ;
Related SDKs SDK Purpose Install Azure.ResourceManager.MySqlMySQL management (this SDK) dotnet add package Azure.ResourceManager.MySqlAzure.ResourceManager.PostgreSqlPostgreSQL management dotnet add package Azure.ResourceManager.PostgreSqlMySqlConnectorMySQL data access dotnet add package MySqlConnector
Reference Links
When to Use This skill is applicable to execute the workflow or actions described in the overview.