Call Azure AD secured API from your SPFx code series:
- Call Azure AD secured API from your SPFx code. Story #1: Azure Functions with cookie authentication (xhr "with credentials")
- Call Azure AD secured API from your SPFx code. Story #1.1: Azure Web App with ASP.NET Core 2.x and cookie authentication (xhr "with credentials") <—you are here
- Call Azure AD secured API from your SPFx code. Story #2: Web app (or Azure Function) and SPFx with adal.js
- Call Azure AD secured API from your SPFx code. Story #3: Web app (or Azure Function) and SPFx with AadHttpClient
In the previous post, I showed an example on how to call Azure Functions API protected with Azure AD (using EasyAuth setup). Described approach has a few limitations, one which is the most important is an inability to send HTTP POST or PUT requests. This issue can be fixed by using regular ASP.NET Web API application with custom authentication layer. More info about this approach you can find here - Access the API by leveraging SharePoint Online authentication cookie. This post describes required steps to make it work:
- Add new app registration in Azure AD
- Create new ASP.NET Core application and setup authentication with Azure AD.
- Enable CORS for your web application with credentials support (so we can send CORS AJAX and attach credentials to our request, auth cookie in our case)
- Create simple SPFx webpart, which gets data from our web app via authenticated HTTP request (GET and POST).
The source code for this article available on GitHub here.
Let’s get started. More...
SPFx has a built-in mechanism, which holds some configuration values for you. For example in runtime, you can read them and determine if you are running locally or not. You can verify if you are in debug mode or not. You can do some other things as well. Let’s take a closer look at some values, available out-of-the box.
Probably you know, that SPFx build pipeline is webpack based. It means, that webpack’s configuration supplies a lot of those values. The most useful are:
process.env.NODE_ENV - can be either ‘production’ or ‘dev’ depending on an environment where the code is running
DEBUG – boolean, equals to false for release builds and true for development
DATACENTER – boolean, equals to true if you are running in context of SharePoint Online. Might be useful if you build webparts for on-prem and Online at the same time More...
A few days ago I published SharePoint REST API Metadata Explorer. In this post I want to share a bit more information about it and share future plans as well.
SharePoint Rest API for long time was a hidden gem for me. I used CSOM or JSOM without issues and that was fine. Nowadays the power of SharePoint REST API increases. Today REST is a recommended way to interact with SharePoint. BTW for a browser there is a great library to manipulate SharePoint REST API using convenient fluent syntax – PnPjs. If you haven’t tried it yet, it’s time to try .
What is always difficult for me with REST API – to find good documentation for different REST API url along with good usage examples. Some information available at docs.microsoft.com, some in blogs and sharepoint.stackexchange site. However there are few issues with mentioned sources:
- they don’t fully cover REST API, there are still a lot of methods which are not yet covered
- in SharePoint Online every month REST API changes and new methods or method params appear
A few years ago I discovered that SharePoint REST API provides WCF $metadata endpoint. More...
Actually for now these libraries are identical and have feature parity. What is the purpose of having two identical libraries? Because PnPjs is an evolution of original PnP-JS-Core. Consider below points regarding new library:
- new organization name (github/pnp) corresponds to npm modules names (@pnp/)
- new library has better structure organization – there are multiple logically divided modules, thus making support and extensibility easier
- new library has exactly the same API and features as current PnP-JS-Core
- new library is a part of SharePoint Pattern & Practices (SharePoint PnP)
- the same people are behind it – Microsoft and awesome community
- development will be performed simultaneously in two libraries for about 5 months. If one feature is available in PnP-JS-Core, this feature also will be added to PnPjs (and vice versa)
- after 5 months (approximately summer 2018) PnP-JS-Core will be deprecated, it will be available in npm and cdn, however it will never receive new features, because main development will be transitioned to PnPjs (pnp/pnp)
What does it mean for you? If you are starting a new project, use new PnPjs library. If you have a chance to perform an upgrade for your current project, upgrade it to PnPjs. If you have a project with PnP-JS-Core – its fine, because the library will be in npm and on cdn, however new feature won’t be rolled out starting from summer 2018 for PnP-JS-Core specifically.
To listen about upcoming changes checkout PnPjs community call – starting from 19:00. If you want to listen to community calls live – use this calendar invite.
Hope this helps!
Last time I blogged about a way to run PnP-PowerShell from VSTS build. This time I’m going to demo on how to run various gulp tasks interacting with SharePoint (upload file for example). Of course, you can easily do that with PnP-PowerShell, however what if you utilize gulp heavily and want to keep everything in one place. Or file upload is a part of your other gulp-based process. Anyway, there might be cases when you want to do that, and here is how.
Start with a new build definition “empty process”. Refer to previous blog to find out how. For our process we need only two simple steps: More...
Visual Studio Team Services (VSTS) is a great way to build and manage the process of building software. If you don’t know what is VSTS, here is a quote from the official docs site:
VSTS is a cloud service for collaborating on code development. It provides an integrated set of features that you access through your web browser or IDE client, including:
- Git repositories for source control of your code
- Build and release management to support continuous integration and delivery of your apps
- Agile tools to support planning and tracking your work, code defects, and issues using Kanban and Scrum methods
- A variety of tools to test your apps, including manual/exploratory testing, load testing, and continuous testing
- Highly customizable dashboards for sharing progress and trends
- Built-in wiki for sharing information with your team
VSTS has a great support for setting up and running CI\CD processes. As part of your CI build definition it’s possible to run PowerShell script as well. And it’s also possible to run PnP-PowerShell scripts, however a few adjustments required.
In today’s post I’m going to describe how you can configure your CI build process to run PnP-PowerShell script. More...
Last year I was learning Power BI via sharepoint.stackexchange analysis, the year is over, it’s time to perform similar analysis on 2017 year! Just a reminder, that everything in this post built with great tool Power BI Desktop and Stack Exchange API as data source. Some advanced data was collected with help of Google Maps Geocode API and nodejs webpages scrapper – osmosis. The source code is available on my github repository.
NOTA: all thoughts here are just my thoughts and may be incorrect or not aligned with yours. Please, share your opinion in comments.
This year I concentrated on verification of some trends from 2016 and mostly on data comparison between 2016 and 2017. So let's get started!
The first difference in the report from the 2016 year, that this time you can try it! You can play with data, change filters, dates and see the actual result. I’ve published all reports to Power BI account (hopefully now I have one as part of my MVP benefit).
Please use this link to see the actual report and play with it.
Or download the report with data from here (zip, 46.45 mb) and play locally.
In the beginning, let's take a look at some changes in tags: More...
Why can’t we use regular http web api instead of WCF web service for our SharePoint RERs? Actually we can! SharePoint makes HTTP POST to any http endpoint, the only task for us is to parse body correctly and send a response back.
In this tutorial I’m going to show how to set up Azure Function, which acts as http endpoint for SharePoint Remote Event Receiver, everything running on Node.js and written in TypeScript! We’ll also use pnp-js-core to interact with SharePoint REST API from event receiver. The source code available at github repo. Let’s get started. More...
A few weeks ago I’ve created an issue around Webpack 2 support for SPFx build pipeline. And there are some good reasons why it’s a good idea to use webpack 2 in SPFx:
- webpack 1 is deprecated
- documentation for webpack 2 is better
- webpack 2 schema more understandable
- sometimes webpack 2 faster (it depends, but still)
- all core webpack loaders supports version 2 and might have issues with previous version down the road
- SPFx introduced as a framework which supports modern web technologies and tools. Someone use Angular, React, someone Vue.js. Vue.js uses webpack 2 and it’s more natural to use webpack 2 with Vue when building SPFx web parts
Finally a few days ago SPFx team released a new version which built with webpack 2! And that’s a good news.
I had to fix all samples around Vue.js and SPFx, because webpack schema is changed. But now I personally feels more comfortable about extending SPFx with Vue.js, because at least they are using the same version of bundler.
Please checkout updated samples with Vue.js in official repository here - https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/vuejs-todo-single-file-component and experimental sample where everything in .vue file (including TypeScript code) - https://github.com/s-KaiNet/spfx-vue-sfc-one-file