DefaultAzureCredential in Visual Studio dev fails to find a suitable user - visual-studio

This is a cool feature that allows an app to get a token via Environment value, visual studio Azure Service Authentication or via MSI if running on Azure. It automatically steps through and find one that works. Great if you are running locally and want to deploy to a web app with MSI later on. It acquires a token from MSI or Visual Studio and some other places
It had been failing unexpectedly when it was working. I have been working with MSFT on this and I figured out what is happening. I'll post an answer.

In Visual Studio, you set the account in the options/Azure Service Authentication/Account Selection ok.
If you debug locally and you have multiple Azure accounts registered in visual studio, you also have to set an environment variable in the webapp properties/debug (or your PC env vars) and adding the env variable AZURE_USERNAME and your selected account email to let it know which one to use.
Here is the problem - if the upper/lower case of your account id does not match the environment variable, it will not connect the two and will not use your visual studio account to authorize. An easy mistake if you add the env variable to the debug properties long after you registered visual studio accounts.
So - check the account on the tools/options/Azure Service Authentication/Account Selection and make sure the case of the AZURE_USERNAME variable is exactly the same.
The github issues is here and a fix is planned.
HTH. M.

Related

cannot Publish web app with Visual Studio 2019 and Azure

There are lots of examples of people having a similar problem to mine, but none of them are the problem that I'm having.
I'm running the Community edition of Visual Studio 2019 (maybe that's the problem). I've already created a free Azure account using the same username/pw/email as the account that I have the version of Visual Studio installed as (note that Azure didn't used to support Core, but it does now).
I'm following this Microsoft Doc on how to create a ASP.NET Core web app with Azure. I've created the project, and it's time to "publish" the web app.
Seems simple: right click on the project >> Publish. Here is the first window, where I should make sure that App Service is highlighted, then hit Create New and Create Profile.
In the next window I can either create my Azure account (which I already have) or sign in. This option seems strange, being that I'm clearly already signed in. Perhaps they mean signed into Azure? In any case, I choose "Already have an account (sign in)" because I do. If I were to choose the first option to create an account, it would tell me that I already have an account.
Next, it asks me to sign into Microsoft Visual Studio account (of which I'm already signed in -- my picture is on the upper right corner of the IDE). I do it anyways:
Next I put in the password (I'll spare you this screenshot -- I showed the last one to illustrate that it wanted me to sign into Visual Studio when I'm already signed in), and...
Nothing.
It takes me back to the App service window. According to the Microsoft doc, the wizard should continue to creating the resource group.
What I've tried:
getting to "Publish" without signing into Visual Studio
getting to "Publish" without signing into Azure (note that the email/pw associated with the Azure account is the same as my Visual Studio account, and I have access to the Azure account; I can go to the Dashboard, at least)
and every variation of being signed into one and not the other or none or both
repeated the entire thing while running Visual Studio 2019 as admin
from the "Pick a publish target" window selecting select existing instead of create new. It takes me to the same window that create new does
instead of .NET Core, using just plain old .NET Framework 4.7.2
What I haven't tried
Uninstalling and reinstalling the Azure SDKs. I'm scared if I do that, then Microsoft won't let me re-install them (because I already have once), and besides, this seems to be a problem with signing in.
Maybe there's some config that I'm missing, either in Visual Studio or Azure?
Maybe it's because I'm using the free Visual Studio version AND the free Azure?
Maybe it knows that I'm laid off and broke, and just wants to push the nail in?
I'm stuck. Does anyone know anything about this?
This question involves both Azure accounts and Visual Studio.To deal with this problem, we can start with these two aspects.
First, we can publish the created project using FTP. If the project runs normally, it means that there is no problem with the free subscription account. The problem may appear on VS.
Second, we can devenv.exe / resetuserdata to clear the personal account cache information on Visual Studio.
I solved the problem, just enable yours directories in visual studio 2019.
Thanks :)
I solved this problem.
After 30 days of a free trial account, when you want to deploy for example a new Azure app service you can see the label "(disabled) free". This is why you cannot proceed with Visual Studio publishing anymore.
I had the same problem with you. I created a new Microsoft account and then a new Azure account. Now Visual Studio allows me to proceed with creating a new profile in order to publish my app.
I hope I helped you.

How to Disable Git Credentials Manager on Windows (Visual Studio 2017)

I got a question regarding Visual Studio 2017 and Git on Windows 7. In our environment, not every user has an individual Windows account as these machines are shared. Sadly, there is no way to change that fact. We are using Bitbucket for managing Git repositories. In this system, every user has its own login.
Because of this, it is very important for us to not save the credentials for each user within the system. Furthermore, we would like to easily switch between the different authors on every commit. The reason for this problem is the fact that the credentials and the actual author of a commit are not connected to each other. But this is a relatively minor issue.
What is more critical is the fact that Visual Studio is storing the credentials of each user to Windows' built-in Credential Manager as a "Generic Credential". This means even after a reboot of the system, the login is saved in Windows and Visual Studio does not ask for them anymore. This is a very critical issue to us. We have tried the following approaches on different systems to eliminate the chance of a local error:
Disable storing passwords in the Credential Manager using the Group Policy Editor: Did not work, because this does not disable storing generic passwords.
Remove the Git Credential Manager from all config files: Did not work in Visual Studio. When using any other Git client, this solves the problem.
Remove the Git Credential Manager executable from the program folder: Did not have any effect
Edit the Registry Key "disabledomaincreds" in the Registry: Did not have any effect
Disable the Credential Manager Service in services.msg: The application could not be started anymore, but Visual Studio still saved the credentials in it
I would appreciate any help regarding this topic. Thanks in advance!

Microsoft Visual Studio Credential Errors on Microsoft Azure Account

I was trying to deploy my web application to Microsoft Azure and as I enter my credentials for my Microsoft account, this error popped up and I'm unable to seek the solution to solve. However, I tried logging in through Microsoft Visual Studio itself and get the same error message as well
[Error In TextForm]
We could not add the account [myemail] 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
May I know what details I need to check in order to solve the following error?
Thanks in advance.
Try this:
Remove the existing account from Visual Studio
Close Visual Studio
Open a developer command prompt
Type devenv.exe /resetuserdata
Restart Visual Studio
Try and enter you credentials
Worked for me.
In my case it was because I recently left a company.
They had referenced my personal account for some reason in their Azure Active Directory and locked down the account.
I could determine I was still part of their directory from the azure portal, on the right after clicking on the user name their directory was here among others.
Just contacted then to remove the reference to my account which looks like this if your email is johndoe#hotmail.com : johndoe_hotmail.com#EST##tenantname.onmicrosoft.com
I removed the Users from Azure Active Directory group which were not having any subscriptions, and it works!!
Try this:
1. Remove existing account
2. Restart
3. Add account

Debugging two projects in two instances of Visual Studio at the same time

When I try to open two projects in two different instances of Visual Studio and run both of them locally in debug mode at the same time (say, a web application and the backend WebService that it uses) I get the error "Unable to start debugging on the web server. A debugger is already attached"
No one else in the office is able to do it either, except for one person, who can't figure out why it only works for him. The virtual directories in my computer's IIS seem to be set up the same way as his (I don't know about the settings).
I was also able to debug from two instances of VS at once at my previous job, so something about the setup here must be different.
I figured it out. Each project needs to be set to a different Application Pool. Found the answer here.
Since the same AppPool was being used by both the Web Application and Web Service, the same process hosted both. That is why as I had already attached the process in one instance of Visual Studio, I could not attach it in the second instance of Visual Studio.
Changing the AppPool had the effect of both being hosted in different host processes and hence they could now be debugged using different instances of Visual Studio.

Azure VM Role Problem

I have been accepected into the beta program for the VM Role.
In the email it says that i need to run a registery script to setup visual studio, i did this fine on my pc before i reinstalled it.
However when i go to link i was sent it doesnt work any more?
Does any one have the registery file or know the settings i need to change.
Thanks
You'll find the instructions in this blog post - http://blog.toddysm.com/2011/02/how-to-deploy-windows-azure-vm-role.html.
For convenience, here's the relevant section of the post:
Please read the notification email carefully! In the email you will find information how to enable VM Role features in the Visual Studio development environment. In essence you need to run one of the scripts below to add new registry key or just change the following [dword] registry key:
HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Windows Azure Tools for Microsoft Visual Studio 2010\1.0\VirtualMachineRoleEnabled​=1
VM Role Features in VS2010 32-bit Registry Script
VM Role Features in VS2010 64-bit Registry Script
The scripts above will enable the Add New Virtual Machine Role in the context menu in Visual Studio.

Resources