title: Microsoft Authentication in ASP.NET Core 2 and Azure App Services
body: <p>I have the following application at <a href="http://www.github.com/jlind0/StratML.NET" rel="nofollow noreferrer">GitHub</a> and have deployed it to <a href="https://stratml.services" rel="nofollow noreferrer">https://stratml.services</a> on an Azure App Service with Authentication defined as Microsoft Account with anymous requests requiring a Microsoft Account sign in. In "prod" this challenge occurs, however <a href="https://stratml.services/Home/IdentityName" rel="nofollow noreferrer">https://stratml.services/Home/IdentityName</a> returns no content.</p>
  
  <p>I have been following <a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/microsoft-logins?tabs=aspnetcore2x" rel="nofollow noreferrer">this</a> and <a href="https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/identity-2x" rel="nofollow noreferrer">this</a> however I do not want to use EntityFramework and from the latter's description it seems to imply if I configure my Authentication scheme correctly I do not have to.</p>
  
  <p>This following code is in my Start class:</p>
  
  <pre><code>        services.AddAuthentication(options =&gt;
          {
              options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.DefaultChallengeScheme = MicrosoftAccountDefaults.AuthenticationScheme;
          }).AddMicrosoftAccount(microsoftOptions =&gt;
          {
              microsoftOptions.ClientId = Configuration["Authentication:AppId"];
              microsoftOptions.ClientSecret = Configuration["Authentication:Key"];
              microsoftOptions.CallbackPath = new PathString("/.auth/login/microsoftaccount/callback");
  
          });
  </code></pre>
  
  <p>Update: Thanks to the first answer I was able to get, it now authorizes to Microsoft and attempts to feedback to my application however I receive the following error: </p>
  
  <pre><code>InvalidOperationException: No IAuthenticationSignInHandler is configured to handle sign in for the scheme: Cookies
  </code></pre>
  
  <p>Please visit <a href="https://stratml.services/Home/IdentityName" rel="nofollow noreferrer">https://stratml.services/Home/IdentityName</a> and the GitHub has been updated.</p>
  
  <pre><code>        services.AddAuthentication(options =&gt;
          {
              options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.DefaultChallengeScheme = MicrosoftAccountDefaults.AuthenticationScheme;
          }).AddCookie(option =&gt;
          {
              option.Cookie.Name = ".myAuth"; //optional setting
          }).AddMicrosoftAccount(microsoftOptions =&gt;
          {
              microsoftOptions.ClientId = Configuration["Authentication:AppId"];
              microsoftOptions.ClientSecret = Configuration["Authentication:Key"];
  
          });
  </code></pre>