Unable to create a database in SQL Server | "The specified max size is invalid"

NoobSlayer 0 Reputation points
2024-10-13T13:01:06.8133333+00:00

I am trying to create a database in SQL server under a subscription and its resource group through Python code, the response I get in the code is 202 but upon checking the logs, it shows failed. I am trying to copy the database from another sub and its sql resource group. Below is the status message:

"statusMessage": "{\"status\":\"Failed\",\"error\":{\"code\":\"ResourceOperationFailure\",\"message\":\"The resource operation completed with terminal provisioning state 'Failed'.\",\"details\":[{\"code\":\"ProvisioningDisabled\",\"message\":\"The specified max size is invalid.\"}]}}"

here is the code that i am using :

db = Database(location=self.server_location,
              sku=Sku(name='GP_gen5',
                      capacity='4'),
              create_mode='copy',
              source_database_id=snap_db.database_resource_id,
              tags=default_tags(pod),
              collation='Latin1_General_100_CI_AS')
sql_client.databases.create_or_update(self.resource_group_name,
                                      self.database_host_name,
                                      self.database_name,
                                      db,
                                      polling=False)
Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,832 questions
0 comments No comments
{count} votes

Accepted answer
  1. Alberto Morillo 33,866 Reputation points MVP
    2024-10-13T16:52:16.87+00:00

    Specifying the max size for the database should solve the issue. See below example:

    db = Database(location=self.server_location,
    sku=Sku(name='GP_gen5',
    capacity='4'),
    create_mode='copy',
    source_database_id=snap_db.database_resource_id,
    tags=default_tags(pod),
    collation='Latin1_General_100_CI_AS',
    max_size_bytes='1073741824')  # Example for 1 GB
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.