Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Azure DocumentDB in Universal App

I'm trying to access an Azure DocumentDB database from a universal app I'm developing. I've created a short sample of code that accesses my database based on the following sample:https://github.com/Azure/azure-documentdb-net/blob/master/tutorials/get-started/src/Program.cs I've put that in a Console Application and it works fine.

Now, just moving this code to my universal app doesn't work as the Microsoft.Azure.Documents.Client.dll cannot be added to the references of the universal app (not targeting the same Framework).

So, I've created a portable class Library that would provide the database access to my solution. I've tried to install Microsoft.Azure.Documents.Client.dll through NuGet, which didn't work. So I've manually added the reference which did seem to work.

But, when trying to compile the code, I get an error on this line:

_client = new DocumentClient(new Uri(_endPointUrl), _authorizationKey);

Error:

CS7069  Reference to type 'SecureString' claims it is defined in 'mscorlib', but it could not be found  MyProject.StorageManager

So it looks like it didn't like the .dll either.

Here's where I am, it seems that each project type in which the documentDB code works cannot be used by an universal app.

Am I missing something?

like image 628
Nooodles Avatar asked Jan 22 '26 08:01

Nooodles


1 Answers

The DocumentDB .NET SDK does not work from a store application, yet. This is something we're working on providing. For now, there are two approaches you can consider

1) use a Middle tier to access DocumentDB (either Azure Mobile Apps, or your own Web Api)

2) use the JavaScript client SDK to talk to DocumentDB directly from the app (but you need to have a service that generates resource tokens for the client to use as using master key on the client is not supported for security reasons).

like image 99
Ryan CrawCour Avatar answered Jan 25 '26 21:01

Ryan CrawCour



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!