The Help Desk demo, Part 1–Creating the project

The first step creating a new website, naturally, is to create a new Visual Studio project.  In this case, it’ll be a new ASP.NET MVC project built in Visual Studio 2015.  I won’t go through the individual steps for creating a new web project, since that information is available in many, many places around the Internet.  The project name for this website will be ‘BusinessApps.HelpDesk’, since the resulting application from this walk through is ultimately designed to be incorporated into the Office 365 Developer Patterns and Practices repository, and that naming scheme matches the existing naming scheme in the repository.

Once the project has been created, we’ll need to add a couple of NuGet packages.  The NuGet Package Manager is available by right clicking on the project name and selecting ‘Manage NuGet packages…’:

image

Once the NuGet Package Manager opens, the ‘AppForSharePointOnlineWebToolkit’, ‘jQuery.UI.Combined’, ‘Microsoft.Owin’, ‘Microsoft.Owin.Security.OpenIdConnect’, and ‘Microsoft.IdentityModel.Clients.ActiveDirectory’ packages can be added.  All of these packages will install additional dependencies.

The SharePoint functionality will also require that Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime be added as references.

image

Next, some appSettings need to be added to the web.config.  Add the following settings:

    <add key="AzureId" value="" />
    <add key="CertThumbprint" value=""/>
    <add key="Tenant" value="jonhussdev.onmicrosoft.com" />
    <add key="OperationsWebsite" value="https://jonhussdev.sharepoint.com/sites/operations" />
    <add key="SharePointSite" value="https://jonhussdev.sharepoint.com"/>

Right now, only the tenant and SharePoint sites are known.  The tenant can either be the X.onmicrosoft.com name or a custom domain, if one has been added.  In my case, I’m going to use ‘jonhussdev.onmicrosoft.com’.  My SharePoint site is ‘https://jonhussdev.sharepoint.com’ and the Operations team site is ‘https://jonhussdev.sharepoint.com/sites/operations’.

To make those and other settings easy to use, a SettingsHelper class is used.  Since there will certainly be other Helper files as the project progresses, it’s probably a good idea to first create a Settings folder and then add the Settings class to that folder.  The Settings class looks like this.

using System.Configuration;

namespace BusinessApps.HelpDesk.Helpers
{
    public class SettingsHelper
    {
        public static string ClientId => ConfigurationManager.AppSettings["AzureId"];
        public static string CertThumbprint => ConfigurationManager.AppSettings["CertThumbprint"];

        public static string AzureADAuthority => @"https://login.windows.net/" + ConfigurationManager.AppSettings["Tenant"];
        public static string AzureADAuthAuthority => @"https://login.windows.net/" + ConfigurationManager.AppSettings["Tenant"] + "/oauth2/token";
        public static string LogoutAuthority => @"https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=";
        public static string GraphUrl => @"https://graph.microsoft.com/v1.0/" + ConfigurationManager.AppSettings["Tenant"] + "/";

        public static string GraphResource => @"https://graph.microsoft.com/";
        public static string SharePointResource => ConfigurationManager.AppSettings["SharePointSite"];

        public static string HelpDeskEmailAddress => ConfigurationManager.AppSettings["HelpDeskEmailAddress"];
    }
}

The Help Desk Demo

The entire source code for the Help Desk demo can be found here https://github.com/OfficeDev/PnP/tree/dev/Solutions/BusinessApps.HelpDesk/, in the Office 365 Dev PnP GitHub repository.

Leave a Reply

Your email address will not be published.