Create and use a database on Azure with Visual Studio Code

An Azure Database for PostgreSQL server resource provides you with a PostgreSQL server.

Create Azure Database with Visual Studio Code

Use this procedure for the following types of resources:

  • PostgreSQL
  • Cosmos DB databases with support for
    • MongoDB
    • Graph (Gremlin)
    • Core (SQL) (previously known as DocumentDB)

Create a PostgreSQL database in Azure explorer

  1. Install the Azure Databases extension for Visual Studio Code.

  2. In Visual Studio Code, select Azure from the activity bar, then select the subscription where you want to create the database resource.

  3. Right-click Cosmos DB and select Create server.

    Partial screenshot showing the Azure explorer with the Cosmos D B node selected with a popup menu showing the `Create Server` option.

Create a MongoDB server

  1. Select Azure Cosmos DB for MongoDB API from the list.

    Partial screenshot of Visual Studio Code's Azure explorer, with the `Create Server` button highlighted.

  2. Use the following table to answer the questions to create the resource.

    Prompt Answer
    Account name Provide a unique name for the resource.
    Capacity model Select Provisioned Throughput for constant usage. Select Serverless for less-frequent usage.
    Resource group Select an existing resource group or create a new resource group. This is a logical unit of all resources associated with a certain product, feature, or website.
    Location Select a location close to you.
  3. The Azure activity log displays the status.

Create a PostgreSQL server in Azure explorer

  1. Select PostgreSQL from the list.

    Partial screenshot of Visual Studio Code's Azure explorer with the first step of the creation process for a Cosmos D B resource shown.

  2. Use the following table to answer the questions to create the resource.

    Prompt Answer
    PostgreSQL server Enter a name for your PostgreSQL server. This name is used as part of the connection string.
    SKU Select the pricing and options SKU.
    Administrator user name Enter an Administrator user name.
    Administrator password Enter an Administrator password, then enter it a second time in the next screen to confirm.
    Resource group Select an existing resource group or create a new resource group. This is a logical unit of all resources associated with a certain product, feature, or website.
    Location Select a location close to you.
  3. The Azure activity log displays the status.

    Partial screenshot showing the Azure activity log while resource creation is in progress.

Next steps