hey folks, I'm trying to create a PostgreSQL db on...
# azure
a
hey folks, I'm trying to create a PostgreSQL db on Azure using the azure-native package in python, but nothing happens, and the command is stuck creating until it times out. Here's the snippet I'm running:
Copy code
db = dbforpostgresql.Server(
        f"ml-db-{stack_name}",
        resource_group_name=resource_group.name,
        location=resource_group.location,
        sku=dbforpostgresql.SkuArgs(
            name="Standard_B1ms",
            tier="GeneralPurpose",
        ),
        administrator_login=POSTGRES_NAME,
        administrator_login_password=POSTGRES_PASSWORD,
        version="14",
    )
Some random errors I've seen:
Copy code
Diagnostics:
  azure-native:dbforpostgresql:Server (ml-db-prod):
    error: resource partially created but read failed autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The requested resource of type 'Microsoft.DBforPostgreSQL/flexibleServers' with name 'ml-db-prodc2c894dc' was not found.": Code="OperationTimedOut" Message="The operation timed out and automatically rolled back. Please retry the operation."
    error: post-step event returned an error: failed to save snapshot: fetching credentials: renewing lease: [403] The provided update token has expired.
f
Sometimes, the Azure API can get a little squirrelly when it comes to validating inputs, especially when some things are implicit in the Azure Portal but not in ARM. As a safety measure, I suggest going to the Azure Portal and going through the steps of creating this DB, then using the
Download a template for automation
link at the
Review + create
step to examine exactly what's being created with what inputs. To be clear, I don't think this will fix your issue, but it should definitely help determine whether the issue is with your code, or if it's time to open a support request with Azure. Good luck!
a
this worked, i was missing "server_name"
Copy code
def create_ml_database(resource_group: resources.ResourceGroup):
    db = dbforpostgresql.Server(
        f"ml-db-{stack_name}",
        server_name=f"ml-db-{stack_name}",
        resource_group_name=resource_group.name,
        location=resource_group.location,
        sku=dbforpostgresql.SkuArgs(
            name="Standard_B2s",
            tier="Burstable",
        ),
        administrator_login=POSTGRES_USER,
        administrator_login_password=POSTGRES_PASSWORD,
        version="14",
        storage=dbforpostgresql.StorageArgs(
            storage_size_gb=128,
        ),
        tags={
            "ElasticServer": "1",
        },
    )

    return db