Python + Dataverse Series – How to run Python Code in Vs Code

Hi Folks,

As you folks know that Python currently is the number #1 programming language with a massive, versatile ecosystem of libraries for data science, AI, and backend web development. This post kicks off a hands‑on series about working with Microsoft Dataverse using Python. We’ll explore how to use the Python SDK to connect with Dataverse, automate data operations, and integrate Python solutions across the broader Power Platform ecosystem. Whether you’re building data-driven apps, automating workflows, or extending Power Platform capabilities with custom logic, this series will help you get started with practical, real‑world examples.

https://www.microsoft.com/en-us/power-platform/blog/2025/12/03/dataverse-sdk-python/

With the release of the Dataverse SDK for Python, building Python-based logic for the Power Platform has become dramatically simpler. In this post, we’ll walk through how to download Python and set it up in Visual Studio Code so you can start building applications that interact with Dataverse using Python. Sounds exciting already. Let’s dive in and get everything set up..

1. Download and install Python from official website below and then install it in your computer.

    https://www.python.org/ftp/python/3.14.3/python-3.14.3-amd64.exe

    2. Install VS Code

    Important: During installation, make sure to check “Add Python to PATH”. This ensures VS Code can detect Python automatically.

    3. After installation, open VS Code and install the Python extension (Microsoft’s official one). This extension enables IntelliSense, debugging, and running Python script

    4. That’s it, you are now able to run Python logic inside Vs Code

    5. Create or Open a Python file in the system, opened a sample file below

    5. If you want to run Python Programmes in your VS Code, follow below options

    a. Select Start Debugging

    b. You will be prompted a window like below

    You can select the first option highlighted above, it automatically runs your Python Code

    This is very easy to setup…

    If you want to continue reading this series, check out the next article.

    Hope this helps…

    Cheers,

    PMDY

    Python + Dataverse Series – #05: Remove PII

    Hi Folks,

    This is in continuation in the Python + Dataverse series, it is worth checking out from the start of this series here.

    At times, there will be a need to remove PII(Personally Identifiable Information) present in the Dataverse Environments, for this one time task, you can easily run Python script below, let’s take example of removing PII from Contact fields in the below example.

    from azure.identity import InteractiveBrowserCredential
    from PowerPlatform.Dataverse.client import DataverseClient
    # Connect to Dataverse
    credential = InteractiveBrowserCredential()
    client = DataverseClient("https://ecellorsdev.crm8.dynamics.com", credential)
    #use AI to remove PII data from the dataverse records, let's say contact records
    def remove_pii_from_contact(contact):
    pii_fields = ['emailaddress1', 'telephone1', 'mobilephone', 'address1_line1', 'address1_city', 'address1_postalcode']
    for field in pii_fields:
    if field in contact:
    contact[field] = '[REDACTED]'
    return contact
    # Fetch contacts with PII (Dataverse client returns paged batches)
    contact_batches = client.get(
    "contact",
    select=[
    "contactid",
    "fullname",
    "emailaddress1",
    "telephone1",
    "mobilephone",
    "address1_line1",
    "address1_city",
    "address1_postalcode",
    ],
    top=10,
    )
    # Remove PII and update contacts
    for batch in contact_batches:
    for contact in batch:
    contact_id = contact.get("contactid")
    sanitized_contact = remove_pii_from_contact(contact)
    # Prepare update data (exclude contactid)
    update_data = {key: value for key, value in sanitized_contact.items() if key != "contactid"}
    # Update the contact in Dataverse
    client.update("contact", contact_id, update_data)
    print(f"Contact {contact_id} updated with sanitized data: {sanitized_contact}")

    If you want to work on this, download the Python Notebook to use in VS Code…

    https://github.com/pavanmanideep/DataverseSDK_PythonSamples/blob/main/Python-DataverseSDK-RemovePII.ipynb

    Cheers,

    PMDY