Repository navigation
Description
Describe the bug
az mysql flexible-server db create --charset utf8mb3 --collation utf8mb3_unicode_ci creates the database with the server defaults (utf8mb4 / utf8mb4_0900_ai_ci on MySQL 8.4) and exits 0. Azure cannot change a database's charset or collation afterwards through ARM, so the database has to be dropped and created again.
The request body puts charset and collation at the top level instead of under properties, so the service ignores them. From --debug:
Request body:
{"name": "probe", "charset": "utf8mb3", "collation": "utf8mb3_unicode_ci"}
database_create_func builds a plain dict and passes it to begin_create_or_update (custom.py#L1631-L1650 at azure-cli-2.92.0). azure-mgmt-mysqlflexibleservers 1.1.0b3 serializes a plain dict as it is, so the flattened charset and collation fields of the Database model never move under properties. The dev branch has the same code.
_create_database, which az mysql flexible-server create uses for its default database, builds the same kind of dict (custom.py#L1615-L1628). I did not test that path.
Related command
az mysql flexible-server db create
To reproduce
az mysql flexible-server db create -g <resource-group> -s <server> -d probe \
--charset utf8mb3 --collation utf8mb3_unicode_ci
az rest --method get \
--url "<server-resource-id>/databases/probe?api-version=2024-12-30" \
--query '{charset: properties.charset, collation: properties.collation}'Expected behavior
The database has charset utf8mb3 and collation utf8mb3_unicode_ci.
Actual behavior
The database has charset utf8mb4 and collation utf8mb4_0900_ai_ci. The command's own output shows these values and it exits 0.
Suggested fix
Send the values under properties, for example {'properties': {'charset': charset, 'collation': collation}}, or pass Database(charset=charset, collation=collation).
Workaround: create the database with an ARM PUT, az rest --method put --url "<server-resource-id>/databases/<name>?api-version=2024-12-30" --body '{"properties": {"charset": "utf8mb3", "collation": "utf8mb3_unicode_ci"}}'.
Environment summary
- azure-cli 2.92.0 (macOS, Homebrew),
azure-mgmt-mysqlflexibleservers1.1.0b3, request API version2025-06-01-preview - Azure Database for MySQL flexible server, MySQL 8.4, General Purpose
- Also seen once on azure-cli 2.90.0
Drafted with Claude AI.
Activity
nabeleon94 commentedon Nov 12, 2026
Thanks for the detailed report. I opened #34412: both
db createand the default database fromflexible-server createnow sendmodels.Database(charset=..., collation=...), so the values go underproperties. Unit tests check the serialized request body.yonzhan commentedon Nov 13, 2026
route to service team