title: Azure AD Cannot hit login.microsoftonline.com/{tenantId}
body: <p>I am trying to create authentication for my App via Azure Active Directory but have had little luck.</p>
  
  <p>I created a new Azure Active Directory instance in portal.azure.com and copied the "Directory ID" (Click on Azure Active Directory and then properties) and still cannot authenticate.</p>
  
  <p>I am trying to use <a href="https://login.microsoftonline.com/" rel="nofollow noreferrer">https://login.microsoftonline.com/</a>{tenantId}. Any suggestions on what I may be doing wrong or need to try in the portal?</p>
  
  <p>Answer:
  The above won't work directly by itself.</p>
  
  <p>You must set up OWIN and enable an OWIN startup class.</p>
  
  <p>This is what the startup class should look like:</p>
  
  <pre><code>app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
  
          app.UseCookieAuthentication(new CookieAuthenticationOptions());
  
          app.UseOpenIdConnectAuthentication(
              new OpenIdConnectAuthenticationOptions
              {
               ClientId = "{Registered app object id}", //This value is found in the app configuration page and is app specific
              Authority = "https://login.microsoftonline.com/{tenantId}" //This value will NEVER change as it is the tenant ID
              });
  </code></pre>