Adding Azure Storage by using Visual Studio Connected Services

With Visual Studio, you can connect any of the following to Azure Storage by using the Connected Services feature:

  • .NET Framework console app
  • ASP.NET Model-View-Controller (MVC) (.NET Framework)
  • ASP.NET Core
  • .NET Core (including console app, WPF, Windows Forms, class library)
  • .NET Core Worker Role
  • Azure Functions
  • Universal Windows Platform App
  • Xamarin
  • Cordova

The connected service functionality adds all the needed references and connection code to your project, and modifies your configuration files appropriately.

Note

This topic applies to Visual Studio on Windows. For Visual Studio for Mac, see Connected services in Visual Studio for Mac.

Prerequisites

Connect to Azure Storage using Connected Services

  1. Open your project in Visual Studio.

  2. In Solution Explorer, right-click the Connected Services node, and, from the context menu, select Add Connected Service.

    Screenshot showing "Add Azure connected service" screen.

  3. In the Connected Services tab, select the + icon for Service Dependencies.

    Screenshot showing "Add Service Dependency" screen.

  4. In the Add Dependency page, select Azure Storage.

    Screenshot showing "Add Azure Storage" screen.

    If you aren't signed in already, sign into your Azure account. If you don't have an Azure account, you can sign up for a free trial.

  5. In the Configure Azure Storage screen, select an existing storage account, and select Next.

    If you need to create a storage account, go to the next step. Otherwise, skip to step 6.

    Screenshot showing "Add existing storage account to project" screen.

  6. To create a storage account:

    1. Select Create a storage account at the bottom of the dialog.

    2. Fill out the Azure Storage: Create new dialog, and select Create.

      Screenshot showing "New Azure Storage account" screen.

    3. When the Azure Storage dialog is displayed, the new storage account appears in the list. Select the new storage account in the list, and select Next.

  7. Enter a connection string name, and choose whether you want the connection string stored in a local secrets file, or in Azure Key Vault.

    Screenshot showing "Specify connection string" screen.

  8. The Summary of changes screen shows all the modifications that will be made to your project if you complete the process. If the changes look OK, choose Finish.

    Screenshot showing "Summary of changes" screen.

  9. The storage connected service appears under the Connected Services node of your project.

  1. Open your project in Visual Studio.

  2. Press Ctrl+Q (or use the Search button in the Visual Studio IDE to the right of the main menu bar).

  3. In Feature search, enter Azure Storage, and choose Azure Storage - Project > Connected Services > Add > Azure Storage.

    Screenshot of using Feature Search to search for Azure Storage.

  4. In the Connect to dependency page, select Azure Storage, and then click Next.

    Screenshot showing connecting to dependency - Azure Storage.

    If you aren't signed in already, sign into your Azure account. If you don't have an Azure account, you can sign up for a free trial.

  5. In the Connect to Azure Storage screen, select an existing storage account, and select Next.

    If you need to create a storage account, go to the next step. Otherwise, skip to the following step.

    Screenshot showing adding an existing storage account to project.

  6. To create a storage account:

    1. Select Create new by the green plus sign.

    2. Fill out the Azure Storage: Create new dialog, and select Create.

      New Azure Storage account.

    3. When the Azure Storage dialog is displayed, the new storage account appears in the list. Select the new storage account in the list, and select Next.

  7. Enter a connection string name, and choose whether you want the connection string stored in a local secrets file, or in Azure Key Vault.

    Screenshot showing how to specify the connection string.

  8. The Summary of changes screen shows all the modifications that will be made to your project if you complete the process. If the changes look OK, choose Finish.

    Screenshot showing the summary of changes.

  9. The storage connected service appears under the Connected Services node of your project.

Next steps

Azure Storage supports blobs and queues, as well as other features.

To learn about working with blobs, you can continue with the quickstart for blob storage, but instead of starting at the beginning, you can start at Azure blobs quickstart (.NET) - Code examples.

To learn about working with queues, start at Azure Queue Storage quickstart (.NET) - Code examples.