https://github.com/sharpcoder/simpleazure
Easily utilize azure simple storage with this small, templated library.
https://github.com/sharpcoder/simpleazure
Last synced: 6 months ago
JSON representation
Easily utilize azure simple storage with this small, templated library.
- Host: GitHub
- URL: https://github.com/sharpcoder/simpleazure
- Owner: SharpCoder
- License: mit
- Created: 2014-09-12T16:26:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-10-20T15:24:11.000Z (over 11 years ago)
- Last Synced: 2024-12-31T17:38:15.008Z (about 1 year ago)
- Language: C#
- Size: 453 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple Azure Helper
The project aims to streamline the azure simple storage library by providing generic, templated methods that you can apply to strongly typed objects. It requires that you have already installed the Azure dependencies. [Go here for details on setting up the dependency](http://www.nuget.org/packages/WindowsAzure.Storage). Once your project has the necessary libraries, using the Azure Simple Storage is really easy.
## Connection String
The first thing you need to do is change the connection string. It is recommended that you use project settings instead of a const string. But for simplicity, you can simply change the following line (first line of code in the AzureHelper.cs file).
```csharp
private static string AzureConnectionString = "UPDATE_CONNECTION_STRING_HERE";
```
## Using
Once you've updated the connection string, you're now ready to integrate the simple storage. Create a new class in the following structure and you're done!
```csharp
public class SampleClass : TableEntity
{
const string AZURE_TABLE = "SampleTable";
public int UserID { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Email { get; set; }
public bool IsCool { get; set; }
public void Upsert()
{
if (string.IsNullOrEmpty(RowKey))
this.RowKey = Guid.NewGuid().ToString();
// Set the partition key
this.PartitionKey = this.RowKey;
AzureHelper.Upsert(AZURE_TABLE, this);
}
public void Delete()
{
AzureHelper.Delete(AZURE_TABLE, this);
}
public List GetList()
{
return AzureHelper.GetList(AZURE_TABLE);
}
public static SampleClass Retrieve(string rowkey)
{
return AzureHelper.Retrieve(AZURE_TABLE, rowkey, rowkey);
}
}
```