
You can use this technique for any type of service that is exposed within a container.

ConclusionĪs you can see you can now use a storage account emulator to be able to test your Azure Storage code.

This uses the environment variable that I setup in the Fixture. GetEnvironmentVariable ( "AZURE_STORAGE_CONN_STRING" ) ) Var storageAccount = CloudStorageAccount.
#Azure storage emulator windows
Working with the Windows Azure Storage Emulator you ask yourself what credentials I should use. When you start to work with Windows Azure Storage Services like blobs or table you will need to specify an account name and a secret key. Var storageAccount = CloudStorageAccount. Windows Azure Storage Emulator and testing servers. Therefore, using this tool also needs to be considered as an alternative. Azurite will continue to be updated to support the latest versions of Azure Storage APIs. Azurite supersedes the Azure Storage Emulator. I will replace the line that uses the predefined variable, CloudStorageAccount.DevelopmentStorageAccount, specifically Azurite is the future storage emulator platform. This is in the case the test needs, for instance, to be run on a local computer.
#Azure storage emulator code
Thus, the connection string will be generated from the container ip in this case.Īs a fallback, if the code does not run on a build server, I use the development storage account default connection string. The TF_BUILD environment variable is set when the build runs on a build server, specifically TFS or Azure DevOps. Possible bug on the emulator but the emulator is deprecatedĭata.Should().BeEquivalentTo(dataSet, option => option.Excluding(memberInfo => ("Compiled") || = "ETag")) however, using the storage emulator (windows), it is returned. also remove eTag as per the api, when odata=minimalmetadata is set, it is not returned (see ) CompiledRead/CompiledWrite from the TableEntity object. } while (token != null & !ct.IsCancellationRequested) Var seg = await table.ExecuteQuerySegmentedAsync(query, token, ct) Var table = cloudTableClient.GetTableReference(tableName) Īwait table.ExecuteAsync(TableOperation.Insert(item)) Var dataSet = Enumerable.Range(1, 5).Select(_ => new FakeEntity Var cloudTableClient = storageAccount.CreateCloudTableClient() Var storageAccount = CloudStorageAccount.DevelopmentStorageAccount In my case it was enough to start the emulator again as described above.Public async Task execute_query_async_should_return_the_expected_records()

The login already has an account under a different user name. The initialization itself, however, resulted in the following error: The storage emulator needs to be initialized. On my machine I also had the situation that the following message appeared at startup: For example, the three required ports can be adjusted there. The CONFIG file of the Azure stroage emulator can be found at C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\. The following steps are necessary to initialize the emulator: If you are not sure whether the emulator is already started, you can query its status as follows:īy the way: If the default ports (three of the number) are already occupied by another program, you can adjust them in the CONFIG file.
