install sql server on ubuntu agent in azure pipelines - sql-server

Using azure ubuntu latest agent. how can I install sql server on ubuntu-latest agent in azure pipelines? tried the following but causing errors
- task: Bash#3
inputs:
targetType: 'inline'
script: |
sudo apt-get update
sudo apt-get install mssql-server

You need to Import the public repository GPG keys and register the SQL Server Ubuntu repository.
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-preview.list)
"
Please refer to the document: Quickstart: Install SQL Server and create a database on Ubuntu

Related

ODBC error 10054 when trying to connect from Docker

I wanted to convert some of my Python scripts to Docker containers. Inside of my Python script, I am using pyodbc to make SQL Server selects and inserts. I found an example of how to do this online and it is not functioning how I would expect.
My dockerfile:
FROM python:3.9
RUN apt-get -y update && apt-get install -y curl gnupg
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
# download appropriate package for the OS version
# Debian 11
RUN curl https://packages.microsoft.com/config/debian/11/prod.list \
> /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN apt-get -y update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql18
# upgrade pip and install requirements.
COPY /requirements.txt /requirements.txt
RUN pip install --upgrade pip
RUN pip install -r /requirements.txt
COPY . /app
WORKDIR /app
CMD [ "python", "myapp.py" ]
myapp.py
cnxn = pyodbc.connect('DRIVER={ODBC Driver 18 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
The error I get is this:
cnxn = pyodbc.connect('DRIVER={ODBC Driver 18 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
pyodbc.OperationalError: ('08001', '[08001] [unixODBC][Microsoft][ODBC Driver 18 for SQL Server]TCP Provider: Error code 0x2746 (10054) (SQLDriverConnect)')
Any help on this would be greatly appreciated.

Problem with apt-key in Microsoft ODBC driver installation for Ubuntu?

These commands are pulled from this site: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16#ubuntu18
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install -y unixodbc-dev
These are Microsoft's official steps to install ODBC drivers on Ubuntu. I am not too familiar with Linux, so I do not know if using the deprecated apt-key commands will cause me any issues in the future. Could someone let me know if this is a reasonable concern? And if it is, what is the best practice to make my environment more stable for the future?
Thanks

Error while installing snowflake connector for python

I am trying to connect snowflake using python, I tried to install "Snowflake connector" for python using below command:
pip install snowflake-connector-python
https://docs.snowflake.com/en/user-guide/python-connector.html
During installation I am facing following error:
ERROR: Could not build wheels for pyarrow which use PEP 517 and cannot be installed directly
Even I faced similar error while installing snowflake connector for python and I used below command and issue got resolved:
python3 -m pip install --no-use-pep517 snowflake-connector-python
Python 3 I have no issue. Only with Python 2.7.
Try this if you are using python3. It is the documenation.
sudo python3 -m pip install setuptools-rust
sudo python3 -m pip install wheel
sudo python3 -m pip install -r https://raw.githubusercontent.com/snowflakedb/snowflake-connector-python/v2.3.9/tested_requirements/requirements_36.reqs
sudo python3 -m pip install snowflake-connector-python==2.3.9

When to want run SQL Server container, docker show sxited status

After the pulling the SQL Server's container, when I want to run it, Docker shows me "exited" status when O execute this command:
docker ps -a
I tried this link but it did not help me:
https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-configure-docker?view=sql-server-ver15#troubleshooting
These are my container logs:
https://paste.fedoraproject.org/paste/dBBFlyulZ1Bera2caa84tA
I using Fedora 29 x86_x64 and my Docker client version is 18.09.6 Build 481bc77 and Docker-Ce is 19.03.4
(Sorry for my bad English)
This is because starting SQL-Server produces an error.
The error can be looked up in the error log.
Unfortunately, you can't access it, becaus the container terminates.
To lookup the error log, you need to have shared that directory...
On the host, create the location where the container stores the data:
sudo mkdir -p /var/opt/mssql
Create the docker-container with the data directory mapped:
docker pull mcr.microsoft.com/mssql/server:2017-latest
docker run -d -p 2017:1433 --name mssql_2017 -e MSSQL_SA_PASSWORD=TOP_SECRET -e ACCEPT_EULA=Y -e MSSQL_PID="Developer" -v /var/opt/mssql:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2017-latest
(note: this maps port 1433 int he container to port 2017 on the host)
then, to start/stop the container:
docker start mssql_2017
docker stop mssql_2017
Now you can now look at the errors in /var/opt/mssql/log on your host machine.
Also, you can check if it works by connecting with sqlcmd:
For Fedora:
sudo su
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
exit
sudo yum clean expire-cache
sudo yum check-update
sudo yum remove mssql-tools unixODBC-utf16-devel
sudo yum install mssql-tools unixODBC-devel
sudo ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd
sqlcmd -S localhost,2017 -U SA -P "<YourPassword>"
For Ubuntu:
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"
sudo apt-get update
sudo apt-get install mssql-tools
sudo ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd
sqlcmd -S localhost,2017 -U SA -P "<YourPassword>"

apache2: unrecognized service in ubuntu 14.04 LTS?

i try to install Apache 2 on my Ubuntu system version is 14.04 LTS,
installation was success full but when i try to restart the Apache its showing unrecognized service , please help me to solve this problem.
Thanks in advance.
To start the apache server, you can use this command:
$ sudo service httpd start
Other available commands are as follows:
$ sudo service httpd restart ## restart the apache server
$ sudo service httpd stop ## stop the server
To list all httpd commands:
$ sudo service httpd
sudo apt-get remove --purge apache2 apache2-utils
sudo apt-get install --reinstall apache2 apache2-utils
sudo service apache2 start
and then check by:
sudo service apache2 status
I faced same problem and solved it by running the following command:
sudo apt-get purge apache2 apache2-utils apache2.2-bin
sudo apt-get autoremove
sudo apt-get install apache2 apache2-utils apache2.2-bin

Resources