Hi all, not sure if this is a python sdk specific ...
# python
l
Hi all, not sure if this is a python sdk specific problem, but my hope is that you have some good input for me on this one. I have wrestled for a while to get my SQL database to scale properly in Azure by change the DTU or pricing tier using the
requested_service_objective_name
param with the
sql.Database
resource. However, it seems like the
import_
param mess things up by try to re-import/create the database again, even if it already exists.
Copy code
sql.DatabasesClient#CreateImportOperation: Failure sending request: StatusCode=400 -- Original Error: Code="Failed" Message="The async operation failed." InnerError={"unmarshalError":"json: cannot unmarshal array into Go struct field serviceError2.details of type map[string]interface {}"} AdditionalInfo=[{"code":"0","details":[{"code":"0","message":"There was an error that occurred during this operation : '\u003cstring xmlns=\"<http://schemas.microsoft.com/2003/10/Serialization/>\"\u003eError encountered during the service operation. ; Exception Microsoft.SqlServer.Management.Dac.Services.ServiceException:Target database is not empty. The import operation can only be performed on an empty database.; \u003c/string\u003e'","severity":"16","target":null}],"innererror":[],"message":"There was an error that occurred during this operation : '\u003cstring xmlns=\"<http://schemas.microsoft.com/2003/10/Serialization/>\"\u003eError encountered during the service operation. ; Exception Microsoft.SqlServer.Management.Dac.Services.ServiceException:Target database is not empty. The import operation can only be performed on an empty database.; \u003c/string\u003e'","target":null}]
The change of the price tier and DTU works fine behind the scenes. After refreshing the resources everything works as expected. Am I doing something wrong here, or is there some way of ignoring the import during resource updates?
Copy code
database = sql.Database(
        resource_name="my_database",
        name="my_database",
        resource_group_name=resource_group.name,
        server_name=sql_server.name,
        requested_service_objective_name=config.get('database.service_objective') or "S0", 
        import_={
                 "administrator_login":sqlserver_username,
                 "administrator_login_password": sqlserver_random_password.result,
                 "operation_mode":"Import",
                 "authentication_type":"SQL",
                 "storage_key":storage_account_bacpac.primary_access_key,
                 "storage_key_type":"StorageAccessKey",
                 "storage_uri":storage_blob_uri
         })
My initial thought was to check if the database already exists with
sql.get_database
and change the import block based on the result, but that seems like a messy solution?