I'm attempting to establish a connection to my SAP Datasphere database using a PowerShell script within an Azure Function App. However, I've encountered a challenge as it seems not feasible to install the necessary drivers directly into the Azure Function App environment, and I'm struggling to identify an appropriate driver for this purpose.
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
$connectionString = @"
Driver={HDBODBC};ServerNode=e510.hanacloud.ondemand.com:443;UID=PROFICO;PWD=8,*SZ_U_s:WvW;
"@
$con = New-Object System.Data.Odbc.OdbcConnection $connectionString
$con.Open()
$sql = "SELECT top 10 MATNR as MaterialNumber, TO_DATE(ERSDA) as CreatedOn, WERKS as Plant, MAKTX as Description, LVORM as DeletionFlag, MTART as MaterialType, BESKZ as ProcurmentType FROM PROFITABILITY_SP.VIEW_MATERIAL_MASTER"
$cmd = New-Object System.Data.Odbc.OdbcCommand $sql, $con
$rdr = $cmd.ExecuteReader()
while ($rdr.Read())
{
Write ($rdr["MaterialNumber"], $rdr["Description"])
}
$rdr.Close()
$con.Close()
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $errorMessage
})
The script is crafted in PowerShell, and I'm facing the following error message:
ERROR: Exception calling "Open" with "0" argument(s): "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
This error indicates an issue with locating the ODBC driver specified in the connection string, making it challenging to connect to the database as intended.