Skip to content

az mysql flexible-server db create ignores --charset and --collation #34410

Open

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-mysqlflexibleservers 1.1.0b3, request API version 2025-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

  1. added
    customer-reported
    Auto-Assign
    Service Attention
    on Nov 12, 2026
  2. nabeleon94 commented on Nov 12, 2026

    @nabeleon94
    Contributor

    Thanks for the detailed report. I opened #34412: both db create and the default database from flexible-server create now send models.Database(charset=..., collation=...), so the values go under properties. Unit tests check the serialized request body.

  3. yonzhan commented on Nov 13, 2026

    @yonzhan
    Collaborator

    route to service team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Auto-AssignMySQLService Attentionact-codegen-extensibility-squadcustomer-reported

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions