Processes in Microsoft 365 for setting up Office apps, redeeming product keys, and activating licenses.
Dear Das,
Yes, you can automate Connect-SPOService without interactive user sign-in, but storing usernames/passwords in scripts is not recommended.
The Microsoft-supported approach for non-interactive SharePoint Online administration is app-based authentication (service principal + certificate) rather than passing user credentials to Connect-SPOService. This is more secure, compliant, and suitable for Azure DevOps pipelines.
Recommendations:
- Use Microsoft Entra ID (Azure AD) App Registration with certificate-based authentication.
- Store the certificate securely (Azure Key Vault, secure certificate store).
- Run the script from Azure DevOps Service Connection, Managed Identity, or a service principal.