Forum Discussion
365 auto generation of vCards with QR Codes on user creation in 365 admin center
Hello,
I wrote a simple python script that creates a QRcode linking to a vCard for a user. Currently this is manually ran in a local terminal by myself.
How can I have this script run automatically whenever I make a user in 365 admin center? My goal is after I have entered all of the user's information this script runs, generates a QR Code as a png file, and places it in a folder on our sharepoint.
Is this possible? I have never used powershell scripts with Microsoft before
1 Reply
- Surya_NarayanaIron Contributor
Use Power Automate (Flow) to Detect New Users
Power Automate can trigger when a new user is created in Microsoft Entra ID (Azure AD).
Trigger to use:
When a user is created (Azure AD) or via HTTP Webhook from Azure Event Grid.
Trigger Your Python Script via Azure Function or HTTP Endpoint
Your Python script can’t run on Power Automate directly, but you have options:
Convert it to an Azure Function (serverless, runs when triggered).
OR
Host it on a VM or local server with an HTTP endpoint (e.g., using Flask).
Then Power Automate can send an HTTP request with the user data.
Get User Data into the Script
Power Automate provides the new user's:
DisplayName, Given Name, Surname, Mail, Job Title, Mobile Phone, etc.
Pass these as a JSON payload to your script’s endpoint.
Save the PNG to SharePoint
In your Python script:
Save the image locally (or in memory).
Use Microsoft Graph API or Office365-REST-Python-Client to upload the file to a SharePoint Document Library.
Permissions & Setup
You'll need:
Azure AD App Registration (to allow Graph API access)
Service principal with write access to SharePoint
Admin permissions to configure Power Automate & Azure