I have created a console application which interacts with Sharepoint Online using Microsoft CSOM and PnP. What I don't understand is how to deploy this code to Sharepoint and run it from Sharepoint. Any help would be greatly appreciated. I have included my code.
static void Main(string[] args)
{
string siteUrl = "";
string userName = "";
SecureString password = new SecureString();
string psd = "";
foreach (char c in psd)
{
password.AppendChar(c);
}
AuthenticationManager am = new AuthenticationManager();
using (var cc = am.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, password))
{
// Demo 1: Add empty page
var page = cc.Web.AddClientSidePage();
page.RemovePageHeader();
page.ClearPage();
var text = new ClientSideText();
text.Text = "Hello PnP";
page.AddControl(text, -1);
page.Save("testpage2.aspx");
page.DisableComments();
page.Publish();
}
}