Code Monkey home page Code Monkey logo

storage-table-dotnet-getting-started's Introduction

services platforms author
storage
dotnet
jasonnewyork

Getting Started with Azure Table Storage in .NET

This demo demonstrates how to perform common tasks using Azure Table storage and Azure Cosmos DB Table API including creating a table, CRUD operations, batch operations and different querying techniques.

If you don't have a Microsoft Azure subscription you can get a FREE trial account here

Note: This sample uses the .NET 4.5 asynchronous programming model to demonstrate how to call the Storage Service using the storage client libraries asynchronous API's. When used in real applications this approach enables you to improve the responsiveness of your application. Calls to the storage service are prefixed by the await keyword. If you don't have a Microsoft Azure subscription you can get a FREE trial account here

Running this sample

Azure Cosmos DB Table API

NOTE: This sample will not work against tables in table account created during the preview period. It will only work against tables created in table accounts created after GA on 11/15/2017.

  1. Go to your Azure Cosmos DB Table API instance in the Azure Portal and select "Connection String" in the menu, select the Read-write Keys tab and copy the value in the "CONNECTION STRING" field.
  2. Open the App.config file and set StorageConnectionString to your connection string.
  3. Load the project in Visual Studio (the community version is available for free)
  4. Run

More Information

-Introduction to Azure Cosmos DB Table API

Azure Table storage

This sample can be run using either the Azure Storage Emulator that installs as part of this SDK - or by updating the App.Config file with your connection string.

To run the sample using the Storage Emulator (default option):

  1. Download and Install the Azure Storage Emulator here.
  2. Start the Azure Storage Emulator (once only) by pressing the Start button or the Windows key and searching for it by typing "Azure Storage Emulator". Select it from the list of applications to start it.
  3. Open App.config and set the value of StorageConnectionString to "UseDevelopmentStorage=true;"
  4. Load the project in Visual Studio (the community version is available for free)
  5. Run

To run the sample using the Storage Service:

  1. Go to your Azure Storage account in the Azure Portal and under "SETTINGS" click on "Access keys". Copy either key1 or key2's "CONNECTION STRING".
  2. Open the app.config file and comment out the connection string for the emulator (UseDevelopmentStorage=True) and uncomment the connection string for the storage service (AccountName=[]...)
  3. Load the project in Visual Studio (the community version is available for free)
  4. Run

More information

storage-table-dotnet-getting-started's People

Contributors

acomsmpbot avatar georgewallace avatar perrysk-msft avatar sanayak avatar tamram avatar yaronyg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

storage-table-dotnet-getting-started's Issues

MethodAccessException: Attempt by method

Trying to instantiate the following class:

namespace Server.Base.Azure.Table.Models
{
public class CosmosDbBase : TableEntity where T : TableEntity, new()
{
public string TableName { get; }
public CloudTable Table { get; }

    public CosmosDbBase(string tableName = "") <<------- Fails Here
    {
        if (string.IsNullOrEmpty(tableName))

           throw new ArgumentNullException("tableName");

        this.TableName = tableName;

        this.Table = CosmosDbStorageAdapter.GetCloudTable(tableName);
    }

I am getting the following error:

MethodAccessException: Attempt by method 'Microsoft.Azure.CosmosDB.Table.TableEntity.set_DisableCompiledSerializers(Boolean)' to access method 'Microsoft.Azure.Storage.Core.Util.PlatformAgnosticReflectionExtensions.FindStaticMethods(System.Type, System.String)' failed.

When I do it for Table storage it works perfectly any ideas whats going wrong?

CosmosDB URL changed - should change method for checking iscosmosdb

Hi guys,

I just stumbled upon an error due to the fact that url for cosmos no longer is .table.cosmosdb. but is .table.cosmos. so the method IsAzureCosmosdbTable in SampleUtils class on line 110 should be changed to look for "table.cosmos" instead of "table.cosmosdb"

Best,
Tomislav

table.ExecuteAsync(insertOrMergeOperation) timing out.

 TableOperation insertOrMergeOperation = TableOperation.Insert(entity);
            // Execute the operation.
            TableResult result = await table.ExecuteAsync(insertOrMergeOperation); //times out.

Microsoft.Azure.Documents.GoneException: Message: The requested resource is no longer available at the server.

I've a question on stack overflow for this here.

Neither this sample or the code I have can do updates.

ExecuteAsync on Azure table storage with Sas Token is giving error

I am using Sas token and trying to perform ExecuteAsync Operation to retrieve data from Azure table storage. At times(Sometimes it works fine) i am getting "object reference not set to an instance of an object" after performing ExecuteAsync. When i run it from the test method it always works. I am sure that Sas token is valid and has all the permissions given. My startup project here is a MicrosoftBotFramework project. The code that i am using to initialize cloud storage account is:

 var sasToken = 
    configurationProvider.GetSetting(CommonConfig.TableStorageSasToken);
    var sasAccount = new StorageCredentials(sasToken);
    cloudStorageAccount = new Lazy<CloudStorageAccount>(() => new 
    CloudStorageAccount(sasAccount, 
    configurationProvider.GetSetting(CommonConfig.StorageAccountName), 
    endpointSuffix: null, useHttps: true), 
    LazyThreadSafetyMode.ExecutionAndPublication);

Code to retrieve data:

var table = await GetTableReference(tableName).ConfigureAwait(false);
           var retrieveOperation = TableOperation.Retrieve<T>(partitionKey, rowKey);
           try
           {
               var retrievedResult = await table.ExecuteAsync(retrieveOperation).ConfigureAwait(false);
               return (T)retrievedResult.Result;
           }

This same method works fine when i directly use the StorageConnection string instead of Sas token. Is there something wrong with my CloudStorageAccount initialization. Same code is being called from Unit test as well and it works fine. Can someone please help me solve this issue? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.