Azure

Azure HTTP PowerShell Perform App To Get Knowledge Utilizing Credentials

Overview

 

This text offers you the essential thought about easy methods to get information from a SharePoint Listing utilizing Azure HTTP PowerShell Perform App with the assistance of userid and password.

 

Steps 

  1. In case you arrange a brand new Azure Surroundings, then first we have to set up SharePointPnPPowerShellOnline
  • Open cloud shell

  • Run command “Set up-Module -Identify SharePointPnPPowerShellOnline”

    Azure HTTP PowerShell Function App To Get Data Using Credentials

  • Go to Perform App, if operate is already Obtainable, we are able to use the identical or we are able to create a brand new one. To create a brand new Perform inside Perform App or new Perform App refer right here.
  • Go to Platform Options of Perform App, scroll down and click on on Superior Instruments (Kudu)

    Azure HTTP PowerShell Function App To Get Data Using Credentials

  • Click on on Debug console and choose CMD

    Azure HTTP PowerShell Function App To Get Data Using Credentials

  • Choose Web site ==> wwwroot ==> click on on Perform Identify folder ==> Add new folder [modules] ==> Add new folder [SharePointPnPPowerShellOnline]
    Below this folder Add All PnP PowerShell associated information.
    Notice
    You possibly can obtain package deal from the beneath URL

    https://www.powershellgallery.com/packages/SharePointPnPPowerShellOnline/3.21.2005.2

    Azure HTTP PowerShell Function App To Get Data Using CredentialsAzure HTTP PowerShell Function App To Get Data Using Credentials

  • Go to the Perform GetData and add the beneath code.
    1. utilizing namespace System.Internet    
    2. Import-Module D:homesitewwwrootGetDatamodulesSharePointPnPPowerShellOnlineNewtonsoft.Json.dll’    
    3. Write-Host “Powershell http set off”    
    4. $requestBody = Get-Content material $req -Uncooked | ConvertFrom-Json    
    5.     
    6. $serviceaccount = $env:Userid    
    7. $serviceaccountpassword = $env:Password    
    8.     
    9. $listname = “[listname]”    
    10. $siteurl = “https://[tenantname].sharepoint.com/websites/[siteurl]”    
    11.     
    12. $secpassword = ConvertTo-SecureString -String $serviceaccountpassword -AsPlainText -Power    
    13. $cred = New-Object -TypeName System.Administration.Automation.PSCredential -ArgumentList $serviceaccount, $secpassword    
    14.     
    15. Join-PnPOnline -Url $siteurl -Credentials $cred    
    16.     
    17. $net = Get-PnPWeb    
    18. $title = $net.Title    
    19. $listitems = Get-PnPListItem -Listing $listname    
    20. $listArray = New-Object System.Collections.Generic.Listing[System.Object]    
    21. foreach ($merchandise in $listitems)    
    22. {    
    23.     $listArray.Add([hashtable]@{    
    24.             DisplayTitle=$merchandise[“Title”];    
    25.             Id= $merchandise[“ID”]    
    26.         }    
    27.     )    
    28. }    
    29. $json = $listArray | ConvertTo-Json    
    30. Out-File -Encoding Ascii -FilePath $res -inputObject $json    
  • Notice

    Please replace tenantname, siteurl, listname

    • Save and attempt to run; it should give error as a result of we didn’t specify Surroundings properties “UserID” & “Password”
    • Go to “Platform Options” ==> Configurations

      Azure HTTP PowerShell Function App To Get Data Using Credentials

    • Click on on + New Utility Setting

      Azure HTTP PowerShell Function App To Get Data Using Credentials

    • After including each Userid & Password the configuration settings will appear to be beneath, then click on on Save.

      Azure HTTP PowerShell Function App To Get Data Using Credentials

    • Go to operate and click on on Run
    • Copy Perform URL and run in browser, it should return information in JSON format.

    Sumamry 

     

    Utilizing Azure Perform App we are able to use SharePoint Knowledge to Open supply, any HTML or different system.

     

    Notice

    This code will work if multifactor authentication isn’t enabled on specified Userid.

     

    If multifactor authentication is enabled then consult with the subsequent weblog.

    Tags
    Show More

    Related Articles

    Leave a Reply

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

    Close