[This is prerelease documentation and is subject to change in future releases.]
The Windows® Azure™ SDK development environment includes development storage, a utility that simulates the Blob, Queue, and Table services available in the cloud. If you are building a hosted service that employs storage services or writing any external application that calls storage services, you can test locally against development storage.
The development storage utility provides a user interface to view the status of the local storage services and to start, stop, and reset them.
This topic contains the following subtopics:
System Requirements
SQL Server Express Authentication
Initializing and Running Development Storage
Generating Database Tables in Development Storage
Authenticating Requests for Development Storage
Development Storage UI
System Requirements
Development storage relies on a Microsoft® SQL Server™ instance to simulate the storage servers. By default, development storage is configured for a Microsoft® SQL Server™ Express versions 2005 or 2008 database.
You can also configure development storage to access a local instance of SQL Server. See Initializing and Running Development Storage below for more information.
If you are running SQL Server Express versions 2005 or 2008, you can also install SQL Server Management Studio Express to manage your SQL Server Express installation.
In order to configure development storage, you must have administrative privileges on the computer.
SQL Server Express Authentication
Development storage connects to SQL Server or SQL Server Express by using Windows authentication.
Initializing and Running Development Storage
To run development storage, locate the DevelopmentStorage.exe tool. By default this tool is installed to the C:\Program Files\Windows Azure SDK\v1.0\bin\ directory.
The first time you run development storage, an initialization process runs to configure the environment. The initialization process creates a database in SQL Server Express and reserves HTTP ports for each local storage service. This step requires administrative privileges. The tool displays a message indicating that the initialization process has completed.
Using the DSInit Tool to Manually Initialize Development Storage
You can run the initialization process separately from development storage by running the DSInit.exe tool. This tool is also installed by default to the C:\Program Files\Windows Azure SDK\v1.0\bin\ directory. After you've initialized the local environment, it's not necessary to call DSInit.exe again.
Note that you must have administrative privileges to call DSInit. See DSInit Tool for more information.
Reinitializing the Database
If you need to reinitialize the database, you can call dsInit /forceCreate to recreate it. Note that this will cause all existing data in the local Blob and Queue service to be lost.
Configuring Development Storage for a Local SQL Server Instance
To configure development storage to run against a local instance of SQL Server, rather than against SQL Express, call DSInit with the /sqlInstance parameter, passing in the name of the target SQL Server instance. Use the name of the SQL Server instance without the server qualifier (e.g., MSSQL instead of .\MSSQL) to refer to a named instance. Use "." to denote an unnamed or default instance of SQL Server.
You can call dsInit /sqlInstance at any time to configure development storage to point to a different instance of SQL Server.
Generating Database Tables in Development Storage
An additional tool, the DevTableGen.exe tool, generates tables for use with the local Table service from a list of managed assemblies. You can use this tool to generate the tables that you need in order to test your service. For usage information for DevTableGen.exe, see DevTableGen Command-Line Tool.
The steps you must take to generate a database and tables in order to use the local Table service are as follows:
-
Within your client code, define classes that model the schema used by your tables. To design your classes, you'll need to use the .NET Client Library for ADO.NET Data Services. The client library provides the DataServiceContext class as part of the System.Data.Services.Client assembly.
-
Run the DevTableGen tool on your compiled assemblies to generate the SQL database.
-
Run development storage and select the database that you have generated as the source for the Table service.
-
If you modify your schema, recompile the assemblies and regenerate the database with the DevTableGen tool with the /forceCreate option.
To call DevTableGen.exe, you must have privileges to create database tables in the SQL Server Express installation. Creating tables requires that you are a member of the sysadmin or dbcreator server roles defined for SQL Server Express.
To generate a database table for use with development storage, construct a class that models the desired schema. The DevTableGen tool reflects over the given set of assemblies for properties of type IQueryable<C> on classes derived from the DataServiceContext class, where C is the class that models your table schema. The class C (or a base class of C) must specify the [DataServiceKey("PartitionKey", "RowKey")] attribute. The DevTableGen tool creates a table with a schema corresponding to the properties defined for class C.
The following code example is derived from the StorageClient Sample. The sample defines a class named SampleDataServiceContext that inherits from DataServiceContext. This class includes a property of type IQueryable<SampleEntity>. This property determines the name for the table. The SampleEntity class defines properties for an entity (which is similar to a row in a table). SampleEntity derives from the TableStorageEntity class, a base class which includes the properties PartitionKey and RowKey. These properties are required for every table in the Table service.
public class SampleEntity : TableStorageEntity
{
public SampleEntity(string partitionKey, string rowKey)
: base(partitionKey, rowKey)
{
C = TableStorageConstants.MinSupportedDateTime;
}
public SampleEntity() : base() {
}
public int A {
get;
set;
}
public string B {
get;
set;
}
public DateTime C {
get;
set;
}
public Guid D
{
get;
set;
}
}
internal class SampleDataServiceContext : TableStorageDataServiceContext
{
internal SampleDataServiceContext(StorageAccountInfo accountInfo)
: base(accountInfo)
{
}
internal const string SampleTableName = "SampleTable";
public IQueryable<SampleEntity> SampleTable
{
get
{
return this.CreateQuery<SampleEntity>(SampleTableName);
}
}
}
The following code example gives the definition for the TableStorageEntity class from which the SampleEntity class derives. Note that it includes the [DataServiceKey("PartitionKey", "RowKey")] attribute.
[CLSCompliant(false)]
[DataServiceKey("PartitionKey", "RowKey")]
public abstract class TableStorageEntity
{
public DateTime Timestamp
{
get;
set;
}
public virtual string PartitionKey
{
get;
set;
}
public virtual string RowKey
{
get;
set;
}
protected TableStorageEntity(string partitionKey, string rowKey)
{
PartitionKey = partitionKey;
RowKey = rowKey;
}
protected TableStorageEntity()
{
}
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
TableStorageEntity rhs = obj as TableStorageEntity;
if (rhs == null)
{
return false;
}
return (this.PartitionKey == rhs.PartitionKey
&& this.RowKey == rhs.RowKey);
}
public override int GetHashCode()
{
if (PartitionKey == null)
{
return base.GetHashCode();
}
if (!String.IsNullOrEmpty(this.RowKey))
{
return this.PartitionKey.GetHashCode() ^ this.RowKey.GetHashCode();
}
else
{
return this.PartitionKey.GetHashCode();
}
}
}
The DevTableGen tool performs some validation in the process of creating tables. For example, if your assembly defines a property of a type that is not supported in The Table service, such as a Decimal type or a reference type, DevTableGen returns an error.
If you modify the schema as modeled by your assembly, you will need to run DevTableGen again to update the tables in development storage.
Authenticating Requests for Development Storage
Development storage supports only a single fixed account and a well-known authentication key. This account and key are the only credentials permitted for use with development storage. They are:
Account name: devstoreaccount1
Account key: Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
Important The authentication key supported by development storage is intended only for testing the functionality of your client authentication code. It does not serve any security purpose. You cannot use your production storage account and key with development storage. You should not use the development storage account with production data.
Development Storage UI
The development storage utility provides a UI for managing the local Blob, Queue, and Table services. You can use this tool to start or stop any of the services, or to reset them. Resetting a service stops the service, cleans all data for that service from the SQL database (including removing any existing blobs, queues, or tables), and restarts the service.
You can use the development storage utility to select the SQL Server Express database to be used by the Table service. From the Tools menu, click Table Service Properties, and then select the desired database from the drop-down menu. You can also select the database by running the DevelopmentStorage.exe tool with the /database option.
When closed, the development storage utility continues to run and is available as an icon in the system tray. To shut down development storage, click Shutdown from the utility's File menu.
See Also