@Khushboo Kumari , thank you for posting this question here. I see that you are getting the "Keyset does not exist"
error, when trying to connect to SharePoint online using the Connect-PnPOnline
cmdlet.
Generally, this error specifically points to the following 2 issues:
- The certificate used/uploaded does not have private key associated with it. OR
- That the user account (which is executing the runbook, in this case the Azure Automation job account) does not have access to the certificate.
Since the issue is happening in Azure Automation, you cannot do much about the 2nd point mentioned above. Therefore, please ensure that the certificate (whose thumbprint is being used in the cmdlet, does have a private ket associated with it).
Please follow the step mentioned below, to ensure that correct type of certificate has been created and it is uploaded to AppRegistration with the private key with it - Granting access via Azure AD App-Only.
If your sharepoint and Azure Automation account are in the same tenant, you can also use Managed Identity to connect to Sharepoint online from Azure Automation. This is much cleaner and does not require certificate based authentication. For details, see Authentication in Azure Automation with Managed Identity on SharePoint and Microsoft Graph
Also, see the guidelines from the official PnP repository: Connect to the SharePoint Online using Application Permissions
Hope this helps.