Friday, May 11, 2018

user_interaction_required – Not able to add/refresh account in VS 2015

One day all of a sudden most of our team members were not able to add/refresh their account in VS 2015. We were getting an error
Microsoft Visual Studio
We could not refresh the credentials for the account xxx

user_interaction_required: One of two conditions was encountered: 1. The PromptBehavior.Never flag was passed, but the constraint could not be honored, because user interaction was required. 2. An error occurred during a silent web authentication that prevented the http authentication flow from completing in a short enough time frame
I then started looking at the network traces to figure out what’s wrong. I saw that there was an interaction between and after which the error would occur.

Now, I saw a prompt to accept Terms Of Use in a different tenant that my home tenant. Looked like someone had enabled a Terms of Use Conditional Access policy on that tenant. See more details about Terms of Use here

On analyzing more, it looks like VS tries to get a token for all the tenants you belong to. If one of the tenant has a Conditional Access policy like Terms of Use which requires a user input, VS 2015 will not be able to show it to you. So will you have to upgrade to VS 2017 or disable the Conditional Access policy.

Once this is done, everything should start working as usual.

Monday, February 26, 2018

Change Azure AD MFA option or phone number

Recently someone asked how can I change my Azure AD MFA option (like call/text/app) or how can I change my phone number.
The easiest way to do this is to go to where you will be able to update your MFA option or phone number.

Wednesday, July 5, 2017

NEWSEQUENTIALID() with Entity Framework and SQL Azure

I was creating on a table in my database on SQL Azure which had a GUID column as the primary key. I wanted to use NEWSEQUENTIALID() instead of NEWID() as the default value for the column because that would generate a sequentially incrementing GUID instead of a random GUID and have better performance.
To do this in entity framework, I added [DatabaseGenerated(DatabaseGeneratedOption.Identity)] attribute on the on column.
I was also using code first migrations. To know more about code first migrations, see
This generates this script
c.Guid(nullable: false, identity: true)
Now when the database would be created in SQL Azure, the column values were still random instead of being sequentially incrementing. But if the same database was created locally on SQL server, the values were sequentially incrementing.
The fix was to change the script to

c.Guid(nullable: false, identity: true, defaultValueSql: "newsequentialid()")

Thursday, December 22, 2016

Redirecting cloud service traffic to load host and port

When you are developing cloud services, sometimes you want to debug the service which is hosted outside of your dev box.
The most common case is that there is a web portal which talks to a web service. The web service is not behaving as expected and you want to debug it.

The easiest step is to add an entry in host file (%SystemRoot%\System32\drivers\etc\hosts)    

Now, when you open the web portal on your dev box, the web service hosted on your dev box will be called and you can debug it by putting breakpoints.

Now comes the interesting part. What if the web service on your dev box is running on a specific port say https://localhost:44310/
Just adding a host entry will not work since you want to redirect the traffic to your host as well as port.

Fiddler comes to rescue here which can be downloaded from
You need to do the following steps:

1. No need to change the host file (%SystemRoot%\System32\drivers\etc\hosts)
2. Open Fiddler
3. Go to Tools->Host and add the below entry
4. Go to Rule->Customize Rules and add the below snippet in static function OnBeforeRequest(oSession: Session)
if (oSession.HostnameIs(""))
5.Restart Fiddler

That’s it, now when you open the web portal on your dev box, the web service hosted on your dev box will be called and you can debug it by putting breakpoints.