Simplify bearer token auth flow in Postman

If you’re developing API’s chances are you are using Postman to test or debug them.
If not, you should totally consider giving it a try, it’s possibly the best productivity tool out there in terms of playing with APIs either developed by you, or someone else.

In this article I want to present you a flow that you can use when working with APIs that require a bearer token for authentication.

Read More

Share Comments

Scaling an Azure Cosmos Db instance with Azure Automation

I wrote before about the need to be able to automatically scale your CosmosDB collections in an attempt to maximize performance while keeping cost at a minimum.

In that article I presented more of a “code-first” solution that you could deploy and use outside the Azure Portal, as a stand-alone tool.

This time, I’m exploring another option, that ties into some preexisting tools that Azure offers - Azure Automation

Read More

Share Comments

5 things you (probably) didn't know about CosmosDB

The more I learn about CosmosDB the more I discover new things that are amazing about it… Today I learned something new (see 2. below) and I wanted to compile and share a list of things that I found interesting and maybe not common knowledge about CosmosDB.

Read More

Share Comments

Announcing CosmosDB Scheduler

One of the great features and selling points of CosmosDB is the elasticity and scale it provides. As we know it does that via the Request Units per second (RUs) that you provision at your collection or database level and that is an indication of your compute capacity as well as cost. The other particularity of this model is that it is a provision based model which means you pay for what you request regardless of how much of it you consume. This often leads to overpaying for resources you never use especially in dev or testing environments as well as in workloads that have a very predictable loads (an app for a store that is closed at night).

Read More

Share Comments

CosmosDB graph and PowerBI - Setting up refreshes

In previous articles I’ve shown how to connect a CosmosDB Graph database to PowerBI for easy reporting and analytics visualization.
An important piece of any dashboard is that it’s up to date and to do that, we need to refresh the data periodically to ensure that we’re visualizing the latest available information.
By default, when you hit refresh in PowerBI, what happens is that all queries behind the dataset are being re-run essentially grabbing all data again. This is certanly not advisable with larger databases both from time and performance perspectives. In order to deal with this problem, PowerBI came with a feature called incremental refresh however it requires a PowerBI Premium license and won’t work with all types of source data.

In this article I’ll be going tghough a technique that mimics the incremental refresh feature and works with our CosmosDB Graph database.

Read More

Share Comments

CosmosDB Graph and PowerBI - Connecting Datasets

In a previous article I showed how you can extract a clean dataset from a CosmosDB Graph database based on one node type (label). It’s likely however that your database contains multiple nodes that are connected with edges to represent relationships. In our reporting we might need the ability to navigate some of those relationships to allow for proper filtering or more complex visualizations.
In this article we’ll explore two techniques to extract those relationships and make them available to PowerBI.

Read More

Share Comments

CosmosDB graph and PowerBI - Getting the data

In this article we will connect a CosmosDB graph collection to PowerBI to enable various kinds of reporting based on the dataset. We will be using the built-in CosmosDB connector available in PowerBI Desktop to connect and access data from our graph using both a wizard-like visual way as well as a more code driven approach.

First up, open PowerBI desktop and find the CosmosDB Connector:

Read More

Share Comments

Manipulating a request body in an Action Filter

An Action Filter is a very neat mechanism to do a bit of pre or post processing on your controller calls.
I’m not going to go much into detail about what they are but essentially they provide a hook to call a piece of code right before or right after the controller code is executed.

In this post I will show how to properly manipulate the Request Body in an Action Filter in a way that does not break it for further processing.

Read More

Share Comments

CosmosDB pricing model

The fundamental pricing unit in cosmos is called Request Unit. The RequestUnit is a measure of throughput and it is an abstraction over compute, memory and IOPS required to serve a request. The idea with the model is that number of request units required for an operation is deterministic so a query will always cost the same. The cost of every operation is returned back to the client via the SDK or response headers so you can always track and manage your cost.

So, what happens if you’re trying to use more than you have provisioned? Every time you issue a request that would consume more resources than available, Cosmos will reject the call and return details about how long you should wait before issuing the query again for best chance of execution.
If you’re using the Cosmos SDK you are going to benefit from a built-in automatic retry policy that will try and seamlessly rerun your query according to the timeouts recommended in Cosmos. If Cosmos still can’t fulfill the request, the SDK will eventually give up (default policy is to retry 5 times) and you will get an “Request rate too large” exception that you will need to handle manually.
With this functionality, often times you don’t even have to worry about exceeding the provisioned resources, assuming you are not getting long-running or very high spikes in load.

Read More

Share Comments

Securing CosmosDB keys with Azure KeyVault

Working with CosmosDB in your applcation is pretty easy. There are tons of tutorials and sample code that shows how you can easily connect your code to ComsosDb and start coding. However, most if not all of them, will at somepoint say [Insert your CosmosDB Key here]. Which means you are essentially taking your most critical piece of defense (your authentication key) and copying it somewhere in your code or configuration. Invariably, at some point it will get into your source control, and that’s just asking for trouble down the line because it’s way harder to restrict access to sensitive information in source control.

Fortunately, there’s an easy (?) way to deal with this problem and it involves a few built-in Azure features like Azure KeyVault and Managed Identity.

Read More

Share Comments