title: User Identity in Azure
body: <p>I'm starting to look at Microsoft Azure, with a view to deploying future web apps there. Most of the apps will have some concept of &quot;user identity&quot;, so one of the wins of using the cloud would be to delegate authentication.</p>
  <p>First step was to create Visual Studio's out-of-the-box MVC application (no authentication) and deploy it, which was surprisingly straightforward.
  Next step was to layer authentication onto this app. I did this purely via the Azure portal, without changing any code. For now just using Azure AD. Again, fine.
  Third step was to write another test rig. I used a Windows Authentication, ASP.NET Core MVC Web App, and in the controller added the code:</p>
  <pre><code>string User = HttpContext.User.Identity.Name;
  if (String.IsNullOrEmpty(User)) User = &quot;&lt;unknown&gt;&quot;;
  
  ViewBag.UserName = User;
  return View();
  </code></pre>
  <p>In the view, added some noddy razor to display the name. Tested locally, fine. Uploaded to Azure, nothing. Neither as an unauthenticated app (as far as the Azure portal goes) or as an Azure AD-authenticated app.</p>
  <p>Digging deeper, I found the Nuget packages Microsoft.Identity and Azure.Identity, which look promising but, right now, are just confusing. I started this just 2 daysago.</p>
  <p>Any pointers?</p>
  <p>I'm looking for a c# asp.net core web app to be deployed to Azure, and for that app to display some kind of recognition that it knows who the end user is. So, basically, some c# code to place in the controller to replace my non-working code.</p>