Skip to content

Instantly share code, notes, and snippets.

View ejazhussain's full-sized avatar
💭
Exploring SPFX , Office 365 and Azure

Ejaz Hussain ejazhussain

💭
Exploring SPFX , Office 365 and Azure
View GitHub Profile
@ejazhussain
ejazhussain / ProjectAssistAgent.cs
Created August 25, 2025 17:14
Defining Project Assist Agent and Assoicated Plugins
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using System.Text;
using System.Text.Json.Nodes;
using O365C.Agent.ProjectAssist.Bot.Plugins;
using O365C.Agent.ProjectAssist.Bot.Models;
namespace O365C.Agent.ProjectAssist.Bot.Agents
@ejazhussain
ejazhussain / project-assist-bot-appsettings.json
Created August 25, 2025 17:11
Project Assist Agent App Settings
{
"AgentApplication": {
"StartTypingTimer": true,
"RemoveRecipientMention": false,
"NormalizeMentions": false,
"UserAuthorization": {
"DefaultHandlerName": "graph",
"AutoSignin": true,
@ejazhussain
ejazhussain / ProjectAssistBot.cs
Created August 25, 2025 17:08
Project Assist Bot
using Microsoft.Agents.Builder;
using Microsoft.Agents.Builder.App;
using Microsoft.Agents.Builder.State;
using Microsoft.Agents.Core.Models;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using O365C.Agent.ProjectAssist.Bot.Agents;
using O365C.Agent.ProjectAssist.Bot.Models;
using O365C.Agent.ProjectAssist.Bot.Services;
@ejazhussain
ejazhussain / SemanticKernelService.cs
Last active March 9, 2025 17:18
Kernel Memory Service
using Microsoft.KernelMemory;
using O365C.SK.KernelMemory.FuncApp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace O365C.SK.KernelMemory.FuncApp.Services
{
@ejazhussain
ejazhussain / CreateDocumentPack.cs
Last active June 30, 2023 19:40
Create PDF document pack using Graph API + TeamFx Azure function extension integration
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Microsoft.Azure.WebJobs.Extensions.TeamsFx;
<Target Name="PostBuild" AfterTargets="PreBuildEvent">
<ZipDir InputBaseDirectory="manifest" OutputFileName="$(OutputPath)\$(MSBuildProjectName).zip" OverwriteExistingFile="true" IncludeBaseDirectory="false" />
</Target>
<UsingTask TaskName="ZipDir" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<InputBaseDirectory ParameterType="System.String" Required="true" />
<OutputFileName ParameterType="System.String" Required="true" />
<OverwriteExistingFile ParameterType="System.Boolean" Required="false" />
<IncludeBaseDirectory ParameterType="System.Boolean" Required="false" />
</ParameterGroup>
@ejazhussain
ejazhussain / GraphService.cs
Created July 29, 2020 21:01
ASP.NET Core - Microsoft Graph API Service
public class GraphService : IGraphService
{
private readonly string serviceEndpoint = "https://graph.microsoft.com/v1.0";
public async Task<UserInfo> GetUserProfileAsync(string accessToken)
{
UserInfo profile = new UserInfo();
try
{
@ejazhussain
ejazhussain / GetOnBehalfAccessTokenAsync.cs
Last active July 29, 2020 20:58
Get access token using On Behalf of Flow - Single Sign On Approach
public async Task<string> GetOnBehalfAccessTokenAsync(string graphScopes, string jwtToken)
{
if (jwtToken == null)
{
throw new ArgumentNullException(jwtToken, "tokenValidationContext.SecurityToken should be a JWT Token");
}
UserAssertion userAssertion = new UserAssertion(jwtToken, "urn:ietf:params:oauth:grant-type:jwt-bearer");
IEnumerable<string> requestedScopes = graphScopes.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries).ToList();
@ejazhussain
ejazhussain / startup-configureservices.cs
Last active July 29, 2020 20:39
ASP.Net Core 3.1 - ConfigureServices method in Startup class to show how to add authentication for API so that only valid request can be made
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddMvc(option => option.EnableEndpointRouting = false);
services.Configure<AzureAdOptions>(Configuration.GetSection("AzureAd"));
services.AddScoped<ITokenAcquisitionService, TokenAcquisitionService>();
services.AddScoped<IGraphService, GraphService>();
services.AddMemoryCache();
import * as React from 'react';
import { useState, useContext, useReducer, useEffect } from 'react';
import ListItemsContext from '../../../../Contexts/ListItemsContext';
import ItemDetail from './ItemDetail';
//Material UI
import { makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableContainer from '@material-ui/core/TableContainer';