Develop with Storage API on Azure Government

Azure Government uses the same underlying technologies as commercial Azure, enabling you to use the development tools you're already familiar with. To use these services in Azure Government, you must define different endpoint mappings, as shown below for the Storage service.

If you don't have an Azure Government subscription, create a free account before you begin.


  • Review Guidance for developers.
    This article discusses Azure Government's unique URLs and endpoints for managing your environment. You must know about these endpoints to connect to Azure Government.
  • Review Compare Azure Government and global Azure and click on a service of interest to see variations between Azure Government and global Azure.
  • Download and install the latest version of Azure Storage Explorer here.

Connecting Storage Explorer to Azure Government

The Microsoft Azure Storage Explorer is a cross-platform tool for working with Azure Storage. Government customers can now take advantage of all the latest features of the Azure Storage Explorer such as creating and managing blobs, queues, tables, and file shares.

Getting Started with Storage Explorer

  1. Open the Azure Storage Explorer desktop application.

  2. You'll be prompted to add an Azure account; in the dropdown choose the "Azure US Government" option:


  3. Sign in to your Azure Government account and you can see all of your resources. The Storage Explorer should look similar to the screenshot below. Click on your Storage Account to see the blob containers, file shares, Queues, and Tables.


For more information on Azure Storage Explorer, navigate here.

Connecting to the Storage API


  • Have an active Azure Government subscription. If you don't have an Azure Government subscription, create a free account before you begin.
  • Download Visual Studio 2019

Getting Started with Storage API

One important difference to note when connecting with the Storage API is that the URL for storage is different than the URL for storage in commercial Azure – specifically, the domain ends with "", rather than "".

These endpoint differences must be taken into account when you connect to storage in Azure Government with C#.

  1. Go to the Azure Government portal and select your storage account and then click the "Access Keys" tab:


  2. Copy/paste the storage account connection string.


  1. Open up Visual Studio and create a new project. Add a reference to the WindowsAzure.Storage NuGet package. This NuGet package contains classes we will need to connect to your storage account.

  2. Add these two lines of C# code to connect:

    var credentials = new StorageCredentials(storageAccountName, storageAccountKey);
    var storageAccount = new CloudStorageAccount(credentials, "", useHttps: true);   
    • Notice on the second line we had to use a particular constructor for the CloudStorageAccount – enabling us to explicitly pass in the endpoint suffix of "". This constructor is the only difference your code requires to connect to storage in Azure Government as compared with commercial Azure.
  3. At this point, we can interact with storage as we normally would. For example, if we want to retrieve a specific record from our table storage we could do it like this:

     var tableClient = storageAccount.CreateCloudTableClient();
     var table = tableClient.GetTableReference("Contacts");
     var retrieveOperation = TableOperation.Retrieve<ContactEntity>("gov-partition1", "0fb52a6c-3784-4dc5-aa6d-ecda4426dbda");
     var result = await table.ExecuteAsync(retrieveOperation);
     var contact = result.Result as ContactEntity;
     Console.WriteLine($"Contact: {contact.FirstName} {contact.LastName}");


  1. Download the Azure Storage SDK for Java and configure your project correctly.

  2. Create a CustomerEntity class in your project and paste the code below:

    public class CustomerEntity extends TableServiceEntity {
            public CustomerEntity(String lastName, String firstName) {
                this.partitionKey = lastName;
                this.rowKey = firstName;
            public CustomerEntity() { }
            String email;
            public String getEmail() {
            public void setEmail(String email) {
       = email;
  3. Create a "test" class where we'll access Azure Table Storage using the Azure Storage API. Copy and paste the code below, and paste your Storage Account connection string into the storageConnectionString variable.

    public class test {
        public static final String storageConnectionString = //Paste in your Storage Account connection string
        public static void main(String[] args) {
            // Retrieve storage account from connection-string.
            CloudStorageAccount storageAccount =
            // Create the table client.
            CloudTableClient tableClient = storageAccount.createCloudTableClient();
            // Create the table if it doesn't exist.
            String tableName = "Contacts";
            CloudTable cloudTable = tableClient.getTableReference(tableName);
            // Create a new customer entity.
            CustomerEntity customer1 = new CustomerEntity("Brown", "Walter");
            // Create an operation to add the new customer to the people table.
            TableOperation insertCustomer1 = TableOperation.insertOrReplace(customer1);
            // Submit the operation to the table service.
        catch (Exception e)
            // Output the stack trace.


  1. Download the Azure Storage SDK for Node.js and configure your application correctly.

  2. The following code below connects to Azure Blob Storage and creates a Container using the Azure Storage API. Paste your Azure Storage account connection string into the storageConnectionString variable below.

    var azure = require('azure-storage');
    var storageConnectionString = //Paste Azure Storage connection string here
    var blobSvc = azure.createBlobService(storageConnectionString);
    blobSvc.createContainerIfNotExists('testing', function(error, result, response){
    // Container exists and is private


  1. Download the Azure Storage SDK for Python.

  2. When using the Storage SDK for Python to connect to Azure Government, you must separately define an "endpoint_suffix" parameter. Paste in your Azure storage account name and key in the placeholders below.

    # Create the BlockBlockService that is used to call the Blob service for the storage account
    block_blob_service = BlockBlobService(account_name='#your account name', account_key='#your account key', endpoint_suffix="") 
    container_name ='ml-gov-demo'
    generator = block_blob_service.list_blobs(container_name)
    for blob in generator:


  1. Download the Azure Storage SDK for PHP.

  2. The code below accesses Azure Table Storage using the Azure Storage API. In the connectionString variable, you'll notice that there's a TableEndpoint parameter. Depending on which service you're using, you must define the parameter and set it to the endpoint for that service:

    • BlobEndpoint= //ends with ''

    • QueueEndpoint= //ends with ''

    • TableEndpoint= //ends with ''


      You can find these endpoints by navigating to your Storage Account from the portal. Paste in your storage account name, key, and service endpoint in the connectionString variable.

      require_once "vendor/autoload.php";
      use WindowsAzure\Common\ServicesBuilder;
      use MicrosoftAzure\Storage\Common\ServiceException; 
      $connectionString = 'DefaultEndpointsProtocol=http;AccountName=<accountname>;AccountKey=<accountkey>;TableEndpoint=http://<storageaccountname>';
      $tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
      try {
      // Create table.
      catch(ServiceException $e){
      $code = $e->getCode();
      $error_message = $e->getMessage();

Get help and provide feedback