SharePoint hosted App: An overview


My SharePoint hosted App uploaded to Microsoft store available at https://sphostedgoogleapp.codeplex.com/

This blog explains about my understanding on App model and SP hosted apps.

Microsoft have added advanced hosting mechanisms to SharePoint 2013, which provides necessary platform to host apps.

SharePoint hosting is a fundamental model in this. Provider hosted is little advanced which will be discussed later.

Development environment:

I am not going to delve deep. But Microsoft recommendation is to have 24GB of RAM for typical dev setup. If you are planning to run Search services, at-least 16GB is recommended. I tried running search SSA’s with my 8GB RAM and It was too slow. Finally after a day of trying various resource utilization techniques I uninstalled Search SSA’s.

After installing SharePoint 2013, follow this excellent article by Mariam to set up App domain.

http://sharepointchick.com/archive/2012/07/29/setting-up-your-app-domain-for-sharepoint-2013.aspx

Understanding of SharePoint hosting:

Microsoft realized Apps/App markets are inevitable to future software industry. To support apps the hosting model plays a key role with isolation, security and storage capabilities. To provide isolation SharePoint apps are created as separate Web apps and for each app installation SharePoint creates a new web app.

This design is made possible through Host web & App Web. App Web is a site dedicated to the App artifacts. When the app is deployed with the list or content type provisions, it will be created in these app-webs. And host webs just use IFrame html viewer to see this data.

Thanks to Chris & Doug for providing a clear explanation.

http://www.sharepointnutsandbolts.com/2012/09/sharepoint-apps-working-with-app-web.html

http://www.elumenotion.com/Blog/Lists/Posts/Post.aspx?ID=171

SharePoint hosted APP:

Install Office developer tools Preview 2 to your Visual studio 2012.

http://blogs.msdn.com/b/officeapps/archive/2012/11/12/announcing-the-latest-release-of-office-developer-tools.aspx

1) Create a Developer site collection form central Admin

2) Open VS & select “App for SharePoint 2013” under VS2012 Office/SharePoint -> Apps

3) Now select Dev site created at step-1 and select “SharePoint-hosted” as options

4) Once VS validates the connection to Dev site, a new App Project will be created.

I my next blog we can see an example of this:

Advertisements

Analysing network traffic – troubleshooting


Many occasions while configuring the FAST SSA’s with custom pipelines, crawl rate will be very less.

Sometimes, the issues might be due to network settings. Follow these steps to debug these issues.

Please see the steps below in order to configure Network Monitor:

1a. Turn off TCP Chimney if any of the machines are Windows 2003
Option 1) Bring up a command prompt and execute the following:
Netsh int ip set chimney DISABLED
Option 2) Apply the Scalable Networking Patch – http://support.microsoft.com/default.aspx?scid=kb;EN-US;936594

1b. Confirm that TCP Chimney is turned off if any of the machines are Windows 2008 and the driver is older than January 2010 (see http://support.microsoft.com/default.aspx/kb/951037 for more details)
a) bring up a command prompt and execute the following:
netsh int tcp show global
b) if it turns out TCP Chimney is on disable it
netsh int tcp set global chimney=disabled

2.  Turn off TCP Offloading/Receive Side-Scaling/TCP Large Send Offload at the NIC driver level

3.  Retry your application.  Don’t laugh – many, many problems are resolved by the above changes.

4.  Download Network Monitor
(http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=983b941d-06cb-4658-b7f6-3088333d062f)

5. Install Network Monitor on both the client and server experiencing the problem.  If you are not able to install it on the server you can install it on another machine that is connected to the same hub as the server or to the admin port of the switch that the server is on.  If you go this route you must synchronize the time between the client, server, and this third machine.

6.  Synchronize the clocks on the Client and SQL machines
a)  At one of the machines bring up a command prompt and execute the following:
Net time <\\machinenamewewanttosynchwith> /set /yes

7. Using the NMCap command-line utility, start the chained trace (chained = create a new capture file after reaching the “Temporary capture file size” rather than overwriting the current capture)
a) [Netmon 3 installation folder]\NMCap /network * /capture /captureprocesses /file test.chn:25M /UseProfile 45c7af5a-d264-4243-90df-fb97082c52ac (creates 25 MB chained files)
b) NOTE:  YOU MUST USE THE .CHN EXTENSION TO CAPTURE CHAINED TRACES
c) NOTE:  The target folder must exist for NMCap to create the trace file

8. Flush DNS
a) ipconfig /flushdns

9) If dealing with an authentication failure, you will now want to purge the Kerberos tickets
a) klist tickets tgt purge

10. Get the IP addresses of the client and the server
a)  ipconfig /all on the client > client.txt
b)  ipconfig /all on the server > server.txt

11. Reproduce the problem, please note the exact time the problem reproduces.  Also, please note the exact error message.

12. Stop the trace by hitting Ctrl-c in the command-line window

IMPORTANT: Please remember to let me know the IP addresses of the server and client as well as the time that the problem occurred.

More information can be found at:

http://blogs.technet.com/netmon/archive/2006/10/24/nmcap-the-easy-way-to-automate-capturing.aspx

OR

by running the command-line switch /examples

OR

by running the command-line switch /?

Powershell script to update masterpage:


Param(
 $csvOutPutName = "masterPageOutput-ts.csv"
 )
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint')
#SCRIPT VARIABLES
 [string]$siteUrl = $args[0]
function GetMissingParameter {
 $script:siteUrl = read-host "Enter Site URL"
 }
function ProcessDirectory($directory, $spfolder) {
 foreach ($file in $directory.GetFiles()) {
 $docUrl = $spfolder.Url + "/" + (Split-Path $file -Leaf)
 $fileToUpdate = $spfolder.ParentWeb.GetFile($docUrl)
if ($fileToUpdate.Exists) {
 $fileToUpdate.CheckOut()
 $newfile = $spfolder.Files.Add($file.Name, $file.OpenRead(), $true)
 $newfile.Update()
 $newfile.CheckIn("Checked-in file via PowerShell script.")
if ($newfile.Level -eq "Draft") {
 $newfile.Publish("Published file via PowerShell script.")
 if ($newfile.Level -ne "Published") {
 $newfile.Approve("Approved file via PowerShell script.")
 }
 }
Write-Host Uploaded file $file.Name to $spfolder.Name
 }
 }
 }
############
 # MAIN
 ############
#IF MISSING PARAM FOR SITE URL OR MANAGED PATH, ASK FOR INPUT TO FILL
 if($args.length -eq 0) {
 GetMissingParameter
 }
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
 $impactedSites = @()
cd Masterpages
 $currentfolder = get-item .
Write-Host "Copying masterpage files to $($site.Url)..." -foregroundcolor Yellow
foreach($web in $site.AllWebs) {
 $obj = New-Object PSObject -property @{ Url = $web.Url; OldCustomMasterPage = $web.CustomMasterUrl; OldMasterPage = $web.MasterUrl; SiteType = "Web"; }
 $obj | fl
$masterpageGallery = $web.GetCatalog(116).RootFolder
 ProcessDirectory $currentfolder $masterpageGallery
$impactedSites += $obj }
cd ..
$site.Dispose()
$impactedSites | ft
 $impactedSites | Export-Csv -Path $csvOutPutName -NoTypeInformation

set primary and secondary Site Collection Administrator through PowerShell


This script reads the CSV in the below format
Url,Owner,SecondaryOwner

and update the primary and secondary admins


#Get Site collection URL as a parameter
 #param(
 #[string] $filePath = $(Throw "Missing Input - CSV file path required with filename. Ex: E:\input\Archivingsites.csv"), #required parameter
 #[string] $LogFilePath = $(Throw "Missing Input - Path to create log file. Path al Ex: E:\input\") #required parameter
 #)

#Load SharePoint dll file
 [void] [System.Reflection.Assembly]::Load(”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

$filePath = "E:\Scripts\UpdateOwnership\UpdateOwnership.csv"
 $csv_info = Import-Csv $filePath

#Logfile Name and Path
 $LogFilePath = "E:\Scripts\UpdateOwnership\"
 $date = ( get-date ).ToString('yyyyMMdd')
 $FileName = "UpdateOwnershipSitesLog_"
 $FileName = $LogFilePath += $FileName += $date

#Creating Log file
 if(!(Test-Path -Path "$FileName.txt"))
 {
 $file = New-Item -type file "$FileName.txt"
 }

Write-Host "--Begin Process--"
 Add-Content -Path "$FileName.txt" -Value "Begin Process"

#iterate Csv File
 foreach ($line in $csv_info)
 {

Write-Host "--starting update for site: " $line.Url " PrimaryOwner: " $line.Owner " & SecondaryOwner: " $line.SecondaryOwner
 Add-Content -Path "$FileName.txt" -Value $( "--starting update for site: " + $line.Url + " PrimaryOwner: " + $line.Owner + " and SecondaryOwner: " + $line.SecondaryOwner)
 #Get site collection
 if($line.Url)
 {
 $site = new-object Microsoft.SharePoint.SPSite($line.Url.Trim())
 $web = $site.RootWeb
 $users = $web.SiteUsers
 if($line.Owner)
 {
 $PrimaryOwner = $web.SiteUsers[$line.Owner.Trim()]

if(!$PrimaryOwner)
 {
 Write-Host "Please add primary owner to " $site
 Add-Content -Path "$FileName.txt" -Value $("Please add primary owner to " + $site)
 }
 else
 {
 $site.set_AllowUnsafeUpdates(1)
 $site.Owner = $PrimaryOwner
 $site.set_AllowUnsafeUpdates(0)
 Write-Host "Primary owner :" $PrimaryOwner "is successfully added to " $site
 Add-Content -Path "$FileName.txt" -Value $("Primary owner: " + $PrimaryOwner + "is successfully added to " + $site)
 }

}
 if($line.SecondaryOwner)
 {
 $SecondaryOwner = $web.SiteUsers[$line.SecondaryOwner.Trim()]
 if(!$SecondaryOwner)
 {
 Write-Host "Please add secondary owner to " $site
 Add-Content -Path "$FileName.txt" -Value $("Please add secondary owner to " + $site)
 }
 else
 {
 $site.set_AllowUnsafeUpdates(1)
 $site.SecondaryContact = $SecondaryOwner
 $site.set_AllowUnsafeUpdates(0)
 Write-Host "Secondary owner :" $SecondaryOwner "is successfully added to " $site
 Add-Content -Path "$FileName.txt" -Value $("Secondary owner: " + $SecondaryOwner + "is successfully added to " + $site )

}
 }
 $site.Dispose()
 }
 }

Add-Content -Path "$FileName.txt" -Value "End Process"
 Write-Host "--End Process--"