This article helps to provide role assignment for Azure Purview account using PowerShell 7.
- Create an Azure Purview account in the Azure portal.
- You need Powershell v7.x.x to use this tool. Please Download and upgrade your Powershell to v7.
- New Version: Import Purview-API-PowerShell 1.10
- OLDER Version: Download and extract Purview-API-Powershell.zip to a folder of your choice.
- Open PowerShell 7 and Run As Administrator
- Navigate to the folder where you have previously downloaded and extracted the Purview-API-PowerShell.
- Run "Purview-API-PowerShell.exe" and enter the name of the Azure Purview account.
You can choose the below options to use the Azure Purview API.
- [G] GUI - Interactive Assistance On Help, Usage & Syntax of Purview APIs
You can use this option to run the query with the helps of GUI.
- [T] Text Mode - Enter API Command(s) Manually
You can use this option to run the query manually by selecting the options available.
- [Q] Quit
- Get the details about the Service Principal/user which you want to add to the role assignment for Purview accounts root collections.
- Get the details about the metadatapolicy by choosing the GET method =>
readAllMetadataPolicies
command - Copy the
Policy ID
from the API Response Recieved. - Get the details about the metadatapolicy by policyID by choosing the GET Method =>
readMetadataPolicyByPolicyID
command - Paste the
Policy ID
and copy entire JSON. - Now paste enter API response in the file name "purview-api-body-payload.json" available in the extracted directory.
!Note: The file "purview-api-body-payload.json" extracted in the same directory contains the API Body to be sent in case of PUT or POST APIs. Make sure to blank the file first, update your JSON into it and save the file before executing any "PUT" or "POST" APIs. If you need to back up your previous JSONs, you may do so in a different file name, since this file name "purview-api-body-payload.json" is reserved for the next upcoming API call.
- Add the user/service principal objectID to the "purview-api-body-payload.json" and save.
- Go back to the PowerShell and select
G
and choose the PUT method =>putMetadataPolicy
command - Now successfully, we had provided the Role Assignments for Purview Account's Root collection using PowerShell.
- You can verfiy the same in Azure Purview Portal.
Go to Data Map => Collections => Select your collection => Role assignments =>Verify the username associated with the objectID.