Azure

Azure HTTP PowerShell Operate App – Get Information Utilizing Shopper ID, Tenant And Thumbprint

Introduction

 

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.

 

Steps 

  • 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.

    1. $password = “*******” | ConvertTo-SecureString -AsPlainText -Pressure  
    2.   
    3. New-PnPAzureCertificate -CommonName “[Name]” -ValidYears 2 -CertificatePassword $password -OutPfx “D:Laptop computer BackupCertificates[filename.pfx]” -OutCert “D:Laptop computer BackupCertificates[filename.cer]”  

    Observe
    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

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • 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)”.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

    Observe
    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

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • Click on on Add Permission.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • Right here, we will choose connectors. We are able to additionally choose any API supported by Azure.
  • Choose SharePoint.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint 

  • On SharePoint API Permissions, request choose “Utility Permissions”.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • Choose the required permission degree. On this case, we have to fetch information, so I chosen “Websites.Learn.All”.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

    Observe
    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.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • 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.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • Click on on Add Certificates.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • After importing a certificates, copy your Thumbprint. Will probably be required in PowerShell script for Web site Authentication.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • 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.

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • Go to the Personal Key Certificates tab and add the non-public certificates which we created with the extension “.pfx”

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • Whereas importing the certificates, present a password which we added whereas creating the certificates

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

  • 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

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

Underneath the code part, paste the beneath code:

  1. utilizing namespace System.Internet  
  2. Import-Module ‘D:homesitewwwroot[FunctionName]modulesSharePointPnPPowerShellOnlineNewtonsoft.Json.dll’  
  3. Write-Host “Powershell http set off”  
  4. $requestBody = Get-Content material $req -Uncooked | ConvertFrom-Json  
  5.   
  6. $tenant = $env:Tenant  
  7. $cleintid = $env:ClientID  
  8. $thumbprint = $env:Thumbprint  
  9. $siteurl = $env:SiteURL  
  10. $listname = “[ListName]”  
  11.   
  12. Join-PnPOnline -Url $siteurl -ClientId $cleintid -Thumbprint $thumbprint -Tenant $tenant  
  13.   
  14. $internet = Get-PnPWeb  
  15. $title = $internet.Title  
  16. $listitems = Get-PnPListItem -Checklist $listname  
  17. $listArray = New-Object System.Collections.Generic.Checklist[System.Object]  
  18. foreach ($merchandise in $listitems)  
  19. {  
  20.     $listArray.Add([hashtable]@{  
  21.             DisplayTitle=$merchandise[“Title”];  
  22.             Id= $merchandise[“ID”]  
  23.         }  
  24.     )  
  25. }  
  26. $json = $listArray | ConvertTo-Json  
  27. 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

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

    Underneath CORS settings add the hostname of the appliance, if you wish to make it open for all Exterior purposes then set “*”

    Azure HTTP PowerShell Function App To Get Data Using Client ID, Tenant And Thumbprint

Abstract

 

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.

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button