Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Azure icon
Labs

Configuring User Access in SQL Server on Linux

With any RDBMS, it is important to appropriately configure both authentication and authorization. Users are provisioned the least privileges possible in order to accomplish their task. In SQL Server, this is accomplished via logins, roles, and users. In this hands-on lab, you are the SQL DBA for Awesome Company. You are working with a developer to set up access for a new web app. This will be accomplished by using the Azure Marketplace to quickly spin up a database back end, then configuring a database appropriately for the developer's needs.

Azure icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 30m
Published
Clock icon Nov 15, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create a SQL Server on Linux VM from the Azure Marketplace

    1. On the home page, click Create a resource at the top of the left panel.
    2. Search for SQL Server 2017 and hit enter.
    3. Filter the search by the criteria:
      • Operating System: Redhat
      • Publisher: Microsoft
    4. Click on Free SQL Server License: SQL Server 2017 Developer on Red Hat Enterprise Linux 7.4 (RHEL).
    5. Click Create.
    6. On the Create a virtual machine page, set the following values:
      • Resource group: Select the one listed
      • Virtual machine name: Anything you'd like
      • Size: B2S
      • Authentication type: Password
      • Username: Anything you'd like
      • Password: Anything you'd like
      • Public inbound ports: Allow selected ports
      • Select inbound ports: SSH (22)
    7. Click Review + create.
    8. Verify that everything looks good, and click Create.
    9. Once the deployment is complete, click Go to resource.
  2. Challenge

    Connect to the SQL Server VM

    1. On the resource page, click Connect at the top.
    2. Use the provided information to log in to the server via SSH.
  3. Challenge

    Change the SA Password

    1. Stop the mssql-server service: sudo systemctl stop mssql-server
    2. Change the SA password: sudo /opt/mssql/bin/mssql-conf set-sa-password
    3. Start the mssql-server service: sudo systemctl start mssql-server
  4. Challenge

    Create Instance Logins

    Create logins for both the developer and the application so they can connect to SQL Server.

    1. Connect to SQL Server locally:
    /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'AwesomePassword!'
    
    1. Create the logins:
    CREATE LOGIN ACApp WITH PASSWORD = 'AppPassword!'
    CREATE LOGIN ACDev WITH PASSWORD = 'DevPassword!'
    GO
    
  5. Challenge

    Create the Database

    1. Create a database for the application:
    CREATE DATABASE AwesomeCompany;
    GO
    
  6. Challenge

    Create Database Users and Assign Permissions

    1. Create the users:
    USE AwesomeCompany;
    GO
    CREATE USER ACApp FOR LOGIN ACApp
    CREATE USER ACDev FOR LOGIN ACDev;
    GO
    
    1. Assign read and write roles to ACApp:
    EXEC sp_addrolemember 'db_datareader', 'ACApp'
    EXEC sp_addrolemember 'db_datawriter', 'ACApp';
    GO
    
    1. Assign the owner role to ACDev:
    EXEC sp_addrolemember 'db_owner', 'ACDev';
    GO
    

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans