3
votes

I am deploying Ubuntu Server 16.04 Canonical nodes to Azure Batch. My Tasks need to access an Azure SQL server database and my code is written in Python.

Before I can use pyodbc, I need to install the Microsoft ODBC Driver 13 for SQL Server.

I've tried following the guide here and added the commands to the Azure Batch Pool StartTask to install the libraries on the nodes, but I am getting errors...

Here are the commands executed by each node on start:

'sudo apt-get update -y && sudo apt-get upgrade -y',
'curl -fSsL https://bootstrap.pypa.io/get-pip.py | python',
'apt-get install -y python3-pip',
'pip3 install azure-storage==0.32.0',
'curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -',
'curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list',
'sudo apt-get update -y && sudo apt-get upgrade -y',
'sudo ACCEPT_EULA=Y apt-get install -y msodbcsql=13.0.1.0-1 mssql-tools-14.0.2.0-1',
'sudo apt-get install -y unixodbc-dev-utf16',
'ln -sfn /opt/mssql-tools/bin/sqlcmd-13.0.1.0 /usr/bin/sqlcmd',
'ln -sfn /opt/mssql-tools/bin/bcp-13.0.1.0 /usr/bin/bcp',
'pip3 install pyodbc'

The above commands (lines 5 to 11 are from the above link) are from the MS documentation...

The node StartTask fails with the following:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   983  100   983    0     0   4397      0 --:--:-- --:--:-- --:--:--  4408
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    79  100    79    0     0    753      0 --:--:-- --:--:-- --:--:--   759
E: Unable to locate package mssql-tools-14.0.2.0-1
E: Couldn't find any package by glob 'mssql-tools-14.0.2.0-1'
E: Couldn't find any package by regex 'mssql-tools-14.0.2.0-1'

If you want to try this yourself, you can use the following tutorial code and modify the task_commands in the create_pool function.

Anyone have any ideas?

2

2 Answers

0
votes

There probably is an issue with the name format of the package mssql-tools-14.0.2.0-1. Have you tried mssql-tools=14.0.2.0-1 instead (note the equals)?

0
votes

Use the below commands to install the ODBC driver and the pyodbc:

sudo apt-get -y update;
export DEBIAN_FRONTEND=noninteractive;
sudo apt-get install -y python3-pip;
apt-get install -y --no-install-recommends apt-utils apt-transport-https;
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - ;
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list ;
sudo apt-get -y update ;
ACCEPT_EULA=Y apt-get -y install msodbcsql17 ;
ACCEPT_EULA=Y apt-get -y install mssql-tools ;
echo 'export PATH=\"$PATH:/opt/mssql-tools/bin\"' >> ~/.bash_profile ;
echo 'export PATH=\"$PATH:/opt/mssql-tools/bin\"' >> ~/.bashrc ;
source ~/.bashrc&& sudo apt-get install -y unixodbc unixodbc-dev ;
sudo pip3 install pyodbc;