Azure HTTP PowerShell Operate App – Get Information Utilizing Shopper ID, Tenant And Thumbprint
This text offers you a fundamental concept about easy methods to Get Information from SharePoint Checklist utilizing Azure HTTP PowerShell Operate App with the assistance of Shopper ID, Tenant & Thumbprint.
- To authenticate a SharePoint Web site with Azure operate App, we require a Personal & Public certificates.
You possibly can generate an Azure Safety certificates utilizing the next PowerShell Instructions.
Open your home windows Powershell or Home windows ISE to run the beneath command.
- $password = “*******” | ConvertTo-SecureString -AsPlainText -Pressure
- New-PnPAzureCertificate -CommonName “[Name]” -ValidYears 2 -CertificatePassword $password -OutPfx “D:Laptop computer BackupCertificates[filename.pfx]” -OutCert “D:Laptop computer BackupCertificates[filename.cer]”
Specify password, Frequent Title, correct path and filename
- Log in to the Azure Portal: https://portal.azure.com
- To fetch information from SharePoint utilizing Operate App we have to register App and supply required Permission to API.
- Go to Azure Lively Listing
- Click on on App Registration
- Give an App Title and choose Entry API.
- If you wish to fetch information from the present Tenant, then choose “Account on this organizational Listing solely (Single Tenant)”.
I’ve offered identify as “ADAppAZSPPnP”
- As soon as App Registration is finished, go to the App.
- Copy Utility (Shopper ID)
- To entry SharePoint information, we have to present Permission to this API. For that, click on on API Permission
- Click on on Add Permission.
- Right here, we will choose connectors. We are able to additionally choose any API supported by Azure.
- Choose SharePoint.
- On SharePoint API Permissions, request choose “Utility Permissions”.
- Choose the required permission degree. On this case, we have to fetch information, so I chosen “Websites.Learn.All”.
This may present chosen Permission to the entire SharePoint tenant.
- As soon as permission is chosen, we have to grant permission. Click on on Grant Admin consent.
- For the registered app, we have to add certificates, which we created earlier.
- For App registration, we have to add a public certificates “.cer”
- Click on on Certificates & secrets and techniques.
- Click on on Add Certificates.
- After importing a certificates, copy your Thumbprint. Will probably be required in PowerShell script for Web site Authentication.
- Go to the Operate App. On operate app, we have to replace configuration settings of the App.
- To Authenticate Operate App with SharePoint utilizing API, we have to add the Personal Key certificates. For that, go to the TLS/SSL settings of the Operate App.
- Go to the Personal Key Certificates tab and add the non-public certificates which we created with the extension “.pfx”
- Whereas importing the certificates, present a password which we added whereas creating the certificates
- Go to the Operate App, if already operate is Accessible, we will use the identical or we will create a brand new one.
To create a brand new operate, discuss with publish 1.
If you happen to create a brand new operate then that you must add SharePointPnP dll recordsdata below the foundation folder of a operate. For more information, discuss with the beneath article.
Create an Azure HTTP Set off PowerShell Operate App
Underneath the code part, paste the beneath code:
- utilizing namespace System.Internet
- Import-Module ‘D:homesitewwwroot[FunctionName]modulesSharePointPnPPowerShellOnlineNewtonsoft.Json.dll’
- Write-Host “Powershell http set off”
- $requestBody = Get-Content material $req -Uncooked | ConvertFrom-Json
- $tenant = $env:Tenant
- $cleintid = $env:ClientID
- $thumbprint = $env:Thumbprint
- $siteurl = $env:SiteURL
- $listname = “[ListName]”
- Join-PnPOnline -Url $siteurl -ClientId $cleintid -Thumbprint $thumbprint -Tenant $tenant
- $internet = Get-PnPWeb
- $title = $internet.Title
- $listitems = Get-PnPListItem -Checklist $listname
- $listArray = New-Object System.Collections.Generic.Checklist[System.Object]
- foreach ($merchandise in $listitems)
- Id= $merchandise[“ID”]
- $json = $listArray | ConvertTo-Json
- Out-File -Encoding Ascii -FilePath $res -inputObject $json
- To test output, click on on run or Copy the Operate URL and run in a browser.
- If you’re attempting to name this API from a particular software, then that you must add an software hostname in Operate App CORS settings.
Go to Operate App API managment ==> CORS
Underneath CORS settings add the hostname of the appliance, if you wish to make it open for all Exterior purposes then set “*”
Utilizing the Azure Operate App, we will use SharePoint Information to Open supply, any HTML, or different methods.
With the usage of Shopper ID, thumbprint & tenant, we need not enter the credentials of the person.