This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = "Stop" | |
#Name of pfx file that needs to be password protected with extension | |
$pfxFileName = Read-Host -Prompt 'Input pfx file name' | |
if($pfxFileName) { | |
#Replace .\ with actual path where .pfx is stored. Do not include file name | |
$pfxFilePath = (Get-Item -Path ".\").FullName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Net | |
# Input bindings are passed in via param block. | |
param($Request, $TriggerMetadata) | |
# Init defaults | |
$status = [HttpStatusCode]::BadRequest | |
$ErrorActionPreference = "STOP" | |
$RequestBody = $Request.Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.Table; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Configuration; | |
/// <summary> | |
/// code to delete data from logs table | |
/// </summary> | |
/// <param name="numberOfDays">days before which all data should be deleted</param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.Table; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Configuration; | |
/// <summary> | |
/// delete old metrics table both PT1H and PT1M | |
/// </summary> | |
/// <param name="tablepPrefix">WADMetricsPT1HP10DV2S and WADMetricsPT1MP10DV2S</param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void InvokeMIP() | |
{ | |
//this client id is for Azure AD app and NOT of SharePoint app | |
private static readonly string clientId = ConfigurationManager.AppSettings["ida:ClientId"]; | |
private static readonly string appName = ConfigurationManager.AppSettings["app:Name"]; | |
private static readonly string appVersion = ConfigurationManager.AppSettings["app:Version"]; | |
private static readonly string mipData = ConfigurationManager.AppSettings["MipData"]; | |
private readonly string mipPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, mipData); | |
try | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class CustomDbContext: DbContext | |
{ | |
public override int SaveChanges() | |
{ | |
// Get all Added/Deleted/Modified entities (not Unmodified or Detached) | |
//you can get updated and deleted in same collection. I am doing so for ease of purpose | |
//getting added entries in different collection to fetch their generated ids and then log them | |
var addedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Added).ToList(); | |
var updatedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Modified).ToList(); | |
var deletedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Deleted).ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller | |
{ | |
private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"]; //clientId | |
private static string appKey = ConfigurationManager.AppSettings["ida:AppKey"]; //clientSecret | |
private static string aadInstance = ConfigurationManager.AppSettings["ida:AADInstance"]; //https://login.windows.net/{0} | |
private static string tenant = ConfigurationManager.AppSettings["ida:Tenant"]; //TenantName.onmicrosoft.com | |
private const string ResourceUri = "https://onenote.com"; | |
public static readonly string Authority = String.Format(CultureInfo.InvariantCulture, aadInstance, tenant);//https://login.windows.net/TenantName.onmicrosoft.com | |
Uri returnUri = new Uri("https://localhost:44327/Home/ReturnFlow"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string filePath = "/TestLibrary/TestDocument.pptx"; | |
var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); | |
using (var sourceContext = spContext.CreateUserClientContextForSPHost()) | |
{ | |
Microsoft.SharePoint.Client.File sourceFile = sourceContext.Web.GetFileByServerRelativeUrl(filePath); | |
//file stream will be used to upload in destination library | |
var fileStream = sourceFile.OpenBinaryStream(); | |
sourceContext.Load(sourceFile, k => k.ServerRelativeUrl, k => k.Name); | |
sourceContext.ExecuteQuery(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.SharePoint.Client; | |
using Microsoft.SharePoint.Client.UserProfiles; | |
using (ClientContext clientContext = new ClientContext("https://tenant.sharepoint.com/")) | |
{ | |
SecureString passWord = new SecureString(); | |
foreach (char c in "your_password".ToCharArray()) passWord.AppendChar(c); | |
clientContext.Credentials = new SharePointOnlineCredentials("your_email_id", passWord); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.SharePoint.Client; | |
using Microsoft.SharePoint.Client.UserProfiles; | |
using (ClientContext clientContext = new ClientContext("https://tenant.sharepoint.com/")) | |
{ | |
SecureString passWord = new SecureString(); | |
foreach (char c in "your_password".ToCharArray()) passWord.AppendChar(c); | |
clientContext.Credentials = new SharePointOnlineCredentials("your_email_id", passWord); |
NewerOlder