Problem with AdomdConnection in Data Factory (PySpark)

Gabriel Hinrichs 0 Reputation points
2024-04-23T16:58:09.58+00:00

I'm trying to connect SSAS (Microsoft Analysis Services) through Data Factory using PySpark with the code below but I'm having problems with Adomd mapping. Apparently there is no reference to the dll but I have no idea where it could be mapped as it is running on Azure (Data Factory - PySpark). Has anyone experienced this difficulty?

NameError: name 'AdomdConnection' is not defined

from pythonnet import load
load("coreclr")

import clr

from pyadomd import Pyadomd
.
.
.
with Pyadomd(connectionString) as conn:
Azure Analysis Services
Azure Analysis Services
An Azure service that provides an enterprise-grade analytics engine.
438 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 15,676 Reputation points
    2024-04-23T19:07:51.64+00:00

    Try to verify that the path to the ADOMD.NET DLL is included in the Python environment's system path. This is crucial for the clr module to locate and reference the DLL correctly.

    Arrange your code to first modify the system path and then import the pyadomd package. Here's how you can do it:

    
    # Specify the path to the ADOMD.NET DLL
    
    dll_path = 'C:\\Program Files\\Microsoft.NET\\ADOMD.NET\\120'
    
    # Add the DLL path to the system path
    
    from sys import path
    
    path.append(dll_path)
    
    # Now import pyadomd package
    
    from pyadomd import Pyadomd
    
    # Your code to use Pyadomd follows here
    
    connection_string = "your_connection_string_here"
    
    with Pyadomd(connection_string) as conn:
    
        # Perform your queries and data operations
    
        pass
    
    

    Ensure that the path you are adding (C:\\Program Files\\Microsoft.NET\\ADOMD.NET\\120) actually contains the Microsoft.AnalysisServices.AdomdClient.dll. This path might differ based on your system configuration or the version of the .NET framework installed.

    Since you are working within Azure Data Factory, make sure that the environment where your code runs can access this path. If you are using a cloud-based integration runtime, the above file path will not be valid, and you may need to consider alternative ways to handle .NET dependencies, such as using a self-hosted integration runtime.