Friday, April 6, 2018

My PowerApps Videos

Demo of using the PowerApps Office365Users Connector and Microsoft Graph to surface User information from Azure Active Directory with the UserId of your CDS (Common Data Service) LastModifiedByUser field.


Editing your CDS (Common Data Service ) Entity with Excel Online from your MacBook




Thursday, August 24, 2017

.NetCore 2.0, AzureAD and OpenIdConnect

.NetCore 2.0, AzureAD and OpenIdConnect

If you develop with .NetCore you probably already know that there are some significant changes from .NetCore 1.1 to .NetCore 2.0
  1. 2.0 — Most .Net Packages are now under a single Namespace — Microsoft.AspNetCore.All
  2. More significant changes are in how we setup our Startup.cs — Configure , ConfigureServices and TokenValidated. 
  3. More, I'm just getting started with 2.0
I had to dig into the Class libraries to figure out how to get this to work in 2.0, the Microsoft docs have not caught up with .NetCore 2.0 just yet, the docs on Authentication still reference 1.1 for now, or maybe I just didn’t look hard enough. 

I’m going to focus on using OpenIdConnect to connect to AzureAD for user authentication in this basic post.

Project setup: 
I put all my Azure connect settings into the appsettings.json file for this post, you may want to put your settings in some other place depending on your security requirements.

app settings.js

“AzureAd” : {
“ClientId”: “
Your ClientId”,
“Tennant”: “
Your Tennant”,
“TennantId “: “
Your TennantId”,
“AADInstance”: “
Your AADInstance”,
“PostLogoutRediredtUri”:”
Your PostLogoutRedirectUri
}, “More settings here, removed for brevity”

You can find these settings on your Azure Portal: 

Azure Active Directory -> App Registrations -> "Your App" -> Properties 

The Code!

.NetCore 1.1

In .NetCore 1.1, I setup the Configure, ConfigureServices, TokenValidated methods of my startup.cs file like this: 

ConfigureServices()

services.AddAuthentication( SharedOptions => SharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme);

Configure()

app.UseCookieAuthentication(new CookieAuthenticationOptions()); 

app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions {
ClientId = _config[“AzureAd:ClientId”],
Authority = String.Format(_config[“AzureAd:AADInstance”],
 _config[“AzureAd:Tenant”]),
ResponseType = OpenIdConnectResponseType.IdToken, 
PostLogoutRedirectUri = _config[“AzureAd:PostLogoutRedirectUri”],
Events = new OpenIdConnectEvents {
OnTokenValidated = TokenValidated,
OnRemoteFailure = OnAuthenticationFailed
 } });

TokenValidated()

private Task TokenValidated(TokenValidatedContext context)
{
string issuer = context.SecurityToken.Issuer;
string subject = context.SecurityToken.Subject;
DateTime validFrom = context.SecurityToken.ValidFrom;
DateTime validTo = context.SecurityToken.ValidTo;
string tenantID = context.Ticket.Principal.FindFirst(“http://schemas.microsoft.com/identity/claims/tenantid").Value;
IEnumerable<string> approvedTenantIds = new List<string>
{
_config[“AzureAd:TenantId”],
_config[“AzureAd:ClientId”]
};
if (!approvedTenantIds.Contains(tenantID))
throw new SecurityTokenValidationException();
return Task.FromResult(0);
}

.NetCore 2.0

Configure()
In 2.0, we no longer need to specify app.UseCookieAuthentication nor app.UseOpenIdConnectAuthentication,
instead all authentication is now available with

app.UseAuthentication(); 

ConfigureServices()

services.AddAuthentication(options=> {
 options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
 options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
 })
 .AddCookie()
 .AddOpenIdConnect(options => {
 options.Authority = String.Format(Configuration[“AzureAd:AADInstance”], Configuration[“AzureAd:Tenant”]);
 options.ClientId = Configuration[“AzureAd:ClientId”];
 options.ResponseType = OpenIdConnectResponseType.IdToken;

 options.Events = new OpenIdConnectEvents
 {
 OnTokenValidated = TokenValidated,
OnRemoteFailure = OnAuthenticationFailed
 };

TokenValidated()In .NetCore 1.1 TokenValidatedContext was located in the namespace 

Microsoft.AspNetCore.Authentication.OpenIdConnect

In .NetCore 2.0 TokenValidatedContext is now under

Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext<OpenIdConnectOptions>

So we need to change how we find the tenantId, everything else is the same as above.

From: 
string tenantID = context.Ticket.Principal.FindFirst(“http://schemas.microsoft.com/identity/claims/tenantid").Value;

To:
string tenantID = context.Principal.FindFirst(“http://schemas.microsoft.com/identity/claims/tenantid").Value;

I did make an addition, I added this to the 2.0 version.
string audience = context.SecurityToken.Audiences.FirstOrDefault();
string upn = context.Principal.FindFirst(ClaimTypes.Upn)?.Value;

OnAuthenticationFailed is the same in both 1.1 and 2.0

 private Task OnAuthenticationFailed(AuthenticationFailedContext context)
 {
 context.HandleResponse();
 context.Response.Redirect(“/Home/Error/?message =” + context.Exception);
 return Task.FromResult(0);
 }

For more information on .NetCore 2.0 changes
https://docs.microsoft.com/en-us/aspnet/core/aspnetcore-2.0

Hope this helps.

Tuesday, January 24, 2017

Microsoft PowerApps and Flow Learning Resources

An ongoing list of Microsoft PowerApps and Flow Resources

I'll update as I come across helpful resources.

Main Sites:
  1. https://powerusers.microsoft.com - Main hub for PowerApps, Flow, Power Bi and Microsoft Stream
  2. https://powerapps.microsoft.com/en-us/ - Documentation on everything PowerApps
  3. https://powerusers.microsoft.com/t5/PowerApps-Community-Blog/bg-p/PowerAppsBlog
  4. Guided Learning - https://powerapps.microsoft.com/en-us/guided-learning/
  5. Documentation on Connectors - https://docs.microsoft.com/en-us/connectors/
Related Technologies

Common Data Model:
  1. MS Ignite - Dive into the Common Data Model - https://www.youtube.com/watch?v=Bf6pR10jA14&t=644s
Azure :

Video - PowerApps

Microsoft:
  1. MS PowerApps - https://www.youtube.com/channel/UCGfWR2ekfRFckLjev6eQYLg
  2. Microsoft Mechanics - Step-by-step guide to building PowerApps for SharePoint: https://www.youtube.com/watch?v=Wr0kmzdR0WY
  3. MS Ignite - Build business applications with Power Apps, Microsoft Flow, and Office 365 - https://www.youtube.com/watch?v=AL84M5U6ZJs&t=833s&spfreload=5
  4. MS Ignite - Dive into PowerApps, building apps that mean business without writing code - https://www.youtube.com/watch?v=fl17EScTdV8&t=1214s
  5. MS Ignite - Dive into Microsoft Flow, create automated workflows between your favorite apps and services - https://www.youtube.com/watch?v=D5dpES5F0l4&t=311s
  6. MS Ignite - Build business applications with Power Apps, Microsoft Flow, and Office 365 - https://www.youtube.com/watch?v=AL84M5U6ZJs&t=833s
  7. MS Ignite - Build business apps for Office 365 - InfoPath, PowerApps, Flow and more - https://www.youtube.com/watch?v=jG3v8xURW2M&t=291s
  8. MS Ignite - Convert InfoPath/Designer workflow processes to PowerApps - https://www.youtube.com/watch?v=vlLqUFsEahg
  9. Channel 9  - https://channel9.msdn.com/Search?term=PowerApps#ch9Search&lang-en=en
  10. Scott Hanselman - PowerApps + Azure App Service for Developers - https://www.youtube.com/watch?v=jbfzTHqukFk&t=89s
  11. Azure Friday with Scott Hanselman and Rob Caron - Arif Kureshy demonstrates https://channel9.msdn.com/Shows/Azure-Friday/PowerApps-and-the-Common-Data-Service
  12. Azure Friday with Scott Hanselman and Rob Caron - Karthik Bharathy demonstrates https://channel9.msdn.com/Shows/Azure-Friday/Extensibility-in-PowerApps
  13. Azure Friday with Scott Hanselman and Rob Caron - Karthik Bharathy demonstrates  https://channel9.msdn.com/Shows/Azure-Friday/PowerApps-101
  14. Azure Friday with Scott Hanselman and Rob Caron - Karthik Bharathy demonstrates  https://channel9.msdn.com/Shows/Azure-Friday/PowerApps-102-Creating-apps-from-templates
  15. Azure Friday with Scott Hanselman and Rob Caron - Karthik Bharathy demonstrates  https://channel9.msdn.com/Shows/Azure-Friday/PowerApps-103-Creating-apps-from-existing-data
  16. Azure Friday with Scott Hanselman - https://channel9.msdn.com/Shows/Azure-Friday/Why-Power-Apps-with-Bill-Staples
  17. Azure Friday with Scott Hanselman - https://channel9.msdn.com/Shows/Azure-Friday/Inside-Web-APIs-and-Swagger-101-with-Brady-Gaster
  18. PowerApps Pro Dev API Experience with Scott Hunter and Guang Yang - https://www.youtube.com/watch?v=iPlTZbsDYT8
  19. Audrie Gordon - https://www.youtube.com/channel/UCspdrsKTBXJTGuco6U3KF0Q - Design, Connectors, porting InfoPath to PowerApps etc...
  20. chassMSFT - https://www.youtube.com/channel/UCPz3udlhfZljjIr1Cze-G6A
  21. MS Ignite sessions list provided by Group Program Manager, PowerApps -  https://powerapps.microsoft.com/en-us/blog/ignite2017/

Non Microsoft:
  1. Laura Rogers - https://www.youtube.com/channel/UCbTVoDCaPM6wE0xsDGGr9VA
  2. Daniel Christian - https://www.youtube.com/channel/UC2v4TcvO4rdDdfqd6rUR5yg

Video - Flow

Microsoft:
  1. Dive into Microsoft Flow, create automated workflows between your favorite apps and services - https://www.youtube.com/watch?v=D5dpES5F0l4
  2. Microsoft Cloud Platform - https://www.youtube.com/watch?v=B1QUo3GiO9Y&list=PL8nfc9haGeb55I9wL9QnWyHp3ctU2_ThF




My PowerApps Videos

Demo of using the PowerApps Office365Users Connector and Microsoft Graph to surface User information from Azure Active Directory with the Us...