Microsoft

Blog Categories

Subscribe to RSS feed

Archives

Follow Microsoft Technologies on Pinterest

Working with dynamic schema in Azure DocumentDB

dynamicAbout a week ago Azure DocumentDB, a new Microsoft’s entry into NoSql database market, become generally available. DocumentDB allows user to to store/update/delete arbitrary objects (as complex as needed, not limited by relation structure) and query these objects using a special (quite limited) flavor of SQL (yes, SQL!) or LINQ when it’s used from .NET. Although these kinds of databases are called NoSql, they should rather be called object databases, or non-relational, because, well, you can still use SQL to query them.

So, these objects that you can story in DocumentDB, they could be really anything. However, in order to effectively use DocumentDB .NET client library, you need to know the object schema in advance. For example, let’s say you have the following class:

public class Person
{
  public string FirstName { get; set; }
  public string LastName { get; set; }
}

And then you instantiating the object of this class and storing it to DocumentDB (assuming that you already created database, document connection and client):

var person = new Person() { FirstName = "John", LastName = "Doe" };
await client.CreateDocumentAsync(collection.SelfLink, person);

So far so good, then let’s retrieve this object back:

person = client.CreateDocumentQuery(collection.SelfLink)
                .Where(p => p.FirstName == "John")
                .AsEnumerable()
                .FirstOrDefault();

This works, but we knew that is a Person and we already have class for Person defined. But what if we don’t have this class defined? Let’s say that we have a set of JSON objects as our data source:

              var data = @"{
                        'FirstName': 'John',
                        'LastName': 'Doeth',
                        'Position': 'Developer',
                        'DOB': '10/12/1973'}";

                    var obj = JsonConvert.DeserializeObject(data);
                    await client.CreateDocumentAsync(collection.SelfLink, obj);

Now we don’t have our Person class any more, we have JSON. Well, we still can query the data… with dynamic SQL:

dynamic person = client.CreateDocumentQuery(collection.SelfLink, "SELECT * FROM root WHERE FirstName = 'John'").ToEnumerable().FirstOrDefault();

The person object, our result, in this case going to be a dynamic object. So, in order to access any of it’s properties we need to know them at compile time:

var firstName = person.FirstName;

But… what if we don’t know the properties as compile time? In our example data comes from JSON, so it could be truly anything. DocumentDB will happily store that “anything”, but how do we work with that data when we retrieve it?
Worse, there is one more issue: ordering. DocumentDB subset of SQL language doesn’t support ordering, so we can’t just write something like SELECT * FROM root WHERE FirstName = ‘John’ ORDER BY FirstName.
If we know the property name at compile time, ordering is not a big problem, we can do is with LINQ (on client side, unfortunately):

client.CreateDocumentQuery(collection.SelfLink, "SELECT * FROM root WHERE FirstName = 'John'").OrderBy(p => p.FirstName)

Well, there is a solution. It’s possible to work with dynamic object properties which we don’t know at compile time, although it’s not pretty. Basically, we need to case dynamic to DynamicObject and then use DynamicObject’s methods to access properties. That process also involves creating CallSite object (basically a runtime compiler services). We can encapsulate this not-that-pretty code into one convenient set of extensions.

Due to the limitations of our blogging platform which is choking on large amounts of code, I’m publishing the extensions to GitHub: https://github.com/starnovsky/DynamicExtensions

With these extensions, querying DocumentDB dynamic schema (i.e. when we don’t have schema defined at compile time) becomes a breeze:
Ordering will look like that:

var person = client.CreateDocumentQuery(collection.SelfLink, "SELECT * FROM root").ToEnumerable().OrderBy("FirstName").FirstOrefault();

We can access dynamic properties too:

DynamicExtensions.PropertyValue(person, "FirstName")

And we can also perform SQL LIKE queries (which DocumentDB SQL is also lacking):

client.CreateDocumentQuery(collection.SelfLink, "SELECT * FROM root").ToEnumerable().WhereContains("LastName", "th")

The code above will return all persons which contains “th” substring in LastName.

Summary:
Azure DocumentDB is a powerful NoSql database as a service and allows to store any object without knowing the object structure in advance (unlike relational database), however it’s hard to query dynamic schema (i.e. when object schema is not known at compile time) which is making DocumentDB less usable when it could be. Provided set of dynamic extensions is making querying dynamic schema objects much simpler.

New Additions to Delve

This post goes one level further in showcasing features within Office 365 which makes day in life more productive (Read the previous post in this series)

In order to get more background on Delve, read my previous articles here

1. Delve

2. Everything about Delve

3. How Delve makes life easier

4. Global Rollout

“Check out your personalized feed of relevant documents. What you see is based on what you and your colleagues are working on. You can easily find colleagues to learn more about them and what they’re working on. Type your name now to see your own page”

This is what it says when you first sign in to Delve. The focus here is around the most important assets for any organization, “People”. Delve is more than just search. It brings over the content and people you have been working with, content and people trending around you, and it does so by learning your behavior over time. I bring here few quick nuggets of information which can help with your everyday work.

Can’t seem to remember the document(s) you’ve been working on or worked on in the past month or so? Go to Delve and select “Me” on the left panel.

Delve6

 

Do you miss the organization chart from MySite in the past? Select “Profile” and you see their contact information, organization chart, OneDrive, blog information etc.

Delve7

 

Delve8

 

Want to find what your coworker is working on? Get to someone’s profile from Delve screen by searching with their name

Delve9

 

Note: Security is still very much respected and others won’t see the content if permissions don’t allow. Here is a message on your Delve home screen to confirm

Delve5

All this is fine but you are a mobile worker and this alone does make the cut for you. Looking for similar experience on mobile devices? Look no further

Note: mobile app only available on android and iPhone

Delve1  Delve2Delve3Delve4

BUILD & IGNITE Know It. Prove It. Tech Challenge Tour

KiPiTour

I recently blogged about my personal experiences with the first “Know it. Prove it.” challenge that ran through the month of February 2015. The “Know it. Prove it.” challenge is back! This time it’s bigger and better than ever. The new challenge is a companion to both the Build and Ignite Conferences with 11 amazing tracks for both Developers and IT Professionals. Also, just like the first round, this set of challenges are completely Free!

Join the tour and accept a challenge today.

Whether you’re looking to learn something new or just brush up on something you’re already using, there’s definitely a challenge track for you.

Read the rest of this post »

2015 Microsoft MVP Virtual Conference – The Power of Community

The Microsoft MVP Virtual Conference is a virtual/remote, 2 day live event on May 14 – 15, 2015. This is a brand new conference presented entirely by Microsoft MVP’s! Conference sessions will be provided in IT Professional, Developer and Consumer tracks, in addition with sessions available in English, Spanish or Portuguese tracks.

2015_MSMVP_VirtualConference_Hero_700x209

The full agenda for the sessions and tracks of the conference is really long. There is a ton of sessions being presented in this conference and it appears to be a very excellent event. Along with it being free to attend, it should be pretty phenomenal. Plus, you don’t have to pay for airfare or hotel accommodations since you can attend from home or work!

Register | Agenda | Sessions

2015 Global Azure Bootcamp

2015-AzureBootcamp_logo_frontThe third annual Global Azure Bootcamp is coming Saturday, April 25, 2015. The bootcamp is a free deep dive into getting familiar with developing Cloud Computing Applications for Azure over the course of a single day. This year there are a total of 194 confirmed locations around the globe where you can attend the event.

http://global.azurebootcamp.net/

In 2014 they leveraged a huge compute farm to perform diabetes research. This year everyone attending will have the opportunity to contribute to a massive compute pool used for performing breast cancer research! Read the rest of this post »

The Skype For Business Client Has Arrived!

Today is the day that the official Skype For Business Client gets released!

I have been using the Technical Preview for about a week now and can honestly say that I like the new Skype-influenced interface. I have a couple customers that have been waiting for this new UI to come out before they begin their client rollout, because they feel that there will be better user adoption due to the familiar Skype interface. Microsoft has released some Client Awareness and Readiness resources to help organizations educate their end users and have a smooth transition to the new interface. These resources can be downloaded here.

This client update is available for the Office Pro Plus and Office 2013 Professional Suite. I am expecting an update to the Mobile client as well but I have yet to see too much information on it and it has yet to show up in my Google Android App Store. The update for the Professional Suite comes in the form of a patch for the Lync 2013 client – KB2889923 – and is currently available via Windows Update. The manual patch installer will eventually be made available here for download.  Depending on your organization’s Lync policies, you may or may not see the new client UI as it can be controlled via a Client Policy with the attribute of EnableSkypeUI and by a registry key – more info on controlling the Skype UI can be found here.

The new client version is 15.0.4711.1002 if you would like to check to see what version you are running.

I did not have any problems updating my Technical Preview client via Windows Update, all that was required was a restart.

Now on to the actual client interface, there are almost too many UI tweaks to cover. I will hit on a few that I think are the best (in no particular order).

  • Call Monitor – this is a compact window that will allow you to monitor the call you are in while the main call window is not up, allowing you to focus on another program. You can see the duration of the call and can mute or end the audio or video call from this collapsed view.
    • Audio Call Screenshot

Skype4B-Call-Monitor

    • Video Call Screenshot

Skype4B-Vid-thumbnail

 

  •  Alert customization – I can control where my alerts appear by choosing between multiple monitors and the position that the alert toasts pop up.

Skype4B-custom-alert

  • Call Window – there is no more hovering to select options!  The new call control button now includes the dial pad, Call Transfer, Hold, Devices, and call volume .

Skype4B-Hold-Transfer-Devices

My only complaint about the new Call Window is that the Participant List, Add New Participant, Instant Messaging, Call Control and Meeting Options are spread out to each corner of the window – depending on your screen real estate this can be a bit of a pain to navigate between but you can tell they had the touch experience in mind.

Skype4B-Window-Options

 

 

 

 

Office 365 – Script to Change UPN between Federated Domains

Nothing too fancy in this post, just a quick script that can help make a nuisance of a task easier…

There’s been a long-standing issue with Office 365 where you cannot change a user’s userPrincipalName (UPN) from one federated domain to another. As an example, if you have federated the domains “company-a.com” and “company-b.com”, changing a user’s UPN suffix between the two will fail.

Given the practice of matching the user’s UPN to their primary email address, it’s feasible that you’ll run across this change at some point, especially in larger environments with many federated domains and people that move between business units.

When attempting to make the UPN change, the tenant’s technical contact will receive a “Directory Synchronization Error Report” email which contains the new userPrincipalName and the user’s immutableID.

In order to remediate the issue, we need the user’s old userPrincipalName; the script below helps with getting the proper value and making the necessary change.
Read the rest of this post »

Azure – NoSQL database DocumentDB now Generally Available

DocumentDB-reliable-configurable-performanceLast week Microsoft released Azure DocumentDB out of beta and made it generally available.

As stated by Microsoft:

We are pleased to announce that Azure DocumentDB is now generally available. DocumentDB is a fully managed NoSQL document database service that allows applications to query and process JSON data at scale. With general availability, DocumentDB is now offered in three purchase options; each with reserved performance, hourly billing and 99.95% availability. Today we are also releasing a new open source data migration tool to ease the movement of existing data from other database systems to DocumentDB.

Source Announcement: http://azure.microsoft.com/blog/2015/04/08/nosql-database-service-azure-documentdb-now-generally-available/

Introduction to Azure DocumentDB

Here’s a short “Introduction to Azure DocumentDB” from Channel9.

Get Started and Pricing

Go to the following link for more information about DocumentDB, including how to get started, pricing and documentation.

http://azure.microsoft.com/en-us/services/documentdb/

Creating Microsoft FIM Management Agent: lessons learned

extensibilityMicrosoft FIM (Frontend Identity Manager) is a popular enterprise product which is allowing to automate user creation, provisioning and de-provisioning in Microsoft Active Directory. FIM has many out-of-the-box extension connectors which allows for connecting FIM to external systems (like external user catalogs), including a set of web services. When out-of-the-box connectors are not sufficient, it’s possible to implement a custom Management Agent (MA) for FIM using .NET framework.

I recently helped to connect FIM to external system which had MySQL user database. There is no out-of-the-box FIM connector for MySQL, we had to implement our own custom management agent. While working on this task I found out that the process of creating FIM MAs is very scarcely documented. This reference and that example is pretty my the only source of information about creating Extensible Connectivity Management Agents (ECMA). The problem though is that the reference doesn’t provide a complete documentation for creating ECMAs and the code example, while providing a complete code listing for management agent, doesn’t cover all everything. In fact, the code sample represents one specific, quite simple case of ECMA 2.2 agents, and there are a couple of places in this example which require additional explanation.

Read the rest of this post »

Enterprise Social Success: Smart Governance to Encourage Adoption

people_connected_by_lines_shutterstock_wordpress

Here at Perficient, we have some real Yammer all-stars, and I have no doubt they’re a big part of the reason we have such a vibrant and active enterprise social network. For example, one Yammer group I am a part of for partner marketers, has brought our team much closer together and allowed us to share countless numbers of ideas, best practices and successes, or simply to ask for advice and get feedback. Before sending an email, I try to ask myself – is this better suited to share on Yammer? A lot of the time, it is. Or, we have a new project and the project team is going back and forth via email – Yammer makes a lot more sense, and it’s quick and easy to spin up a new group for this purpose.

For success and self-sustaining engagement with an enterprise social platform such as Yammer, it’s important to include certain steps on your “social journey,” as Rich Wood demonstrated at the start of a recent webinar, “Succeed with Yammer: Encouraging Adoption with Smart Social Governance.” Paying careful attention to governance, defining use cases, planning for communication and training activity, and creating an internal change champion network are all critical components to achieving this success.

In terms of governance, Rich explained that WHY you are using Yammer drives HOW you choose to govern it. SharePoint is all about document collaboration, and Yammer… not so much. Yammer is about social collaboration – it’s all about the people.

After reviewing different governance controls and options, as well as analytics, Rich passed to torch to Joe Crabtree, who covered how to mobilize your network. Joe discussed the importance of identifying a community manager and the role that individual needs to play. Next, he talked about your team of change champions, and how to gain executive presence on your enterprise social network. Lastly, Joe discussed the best ways to grow, moderate and engage your network. Read the rest of this post »