Archive for the ‘Microsoft Azure’ Category

Powershell error – Import-Module : File AzureRM.psm1 cannot be loaded because running scripts is disabled on this system

After installing the AzureRM module, I tried to import it, but it gave me an error:

Import-Module : File C:\Program Files\WindowsPowerShell\Modules\AzureRM\4.0.2\AzureRM.psm1 cannot
be loaded because running scripts is disabled on this system. For more information, see
about_Execution_Policies at
At line:1 char:1
+ Import-Module AzureRM
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleComman

This error means that the AzureRM module downloaded from internet must be signed by a trusted publisher before they can be run.

–> Now to fix it you need to change the execution policy by this simple command:

PS c:\> Set-ExecutionPolicy RemoteSigned

If you are on PowerShell Window then it will throw a popup to confirm to change the Execution policy, you can choose “Yes”:

Now try running again the import command, it will run:

PS c:\> Import-Module AzureRM


Powershell error – The term ‘Login-AzureRmAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program

If you are new to PowerShell like me then you would have encountered this ans similar errors.

Recently while executing one PowerShell script to connect to Azure Resource Manager I faced following error:

XyzPSScript.ps1 : The term ‘Login-AzureRmAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [XyzPSScript.ps1], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,XyzPSScript.ps1

This error means that you do not have Azure PowerShell module installed on your system or server.

–> So, let’s see how to install the dependent modules.

1. Connect to PowerShell from command prompt (CMD) in Admin mode:

c:\> powershell.exe

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.


2. Check the version of PowerShell:

PS c:\> $PSVersionTable.PSVersion

Major Minor Build Revision
—– —– —– ——–
5 1 14409 1005


3. Run the below command to check if you have PowerShellGet installed on your system:

PS c:\> Get-Module PowerShellGet -list | Select-Object Name,Version,Path

Name Version Path
—- ——- —-
PowerShellGet C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\\PowerShellGet.psd1


4. Now we can easily install the Azure PowerShell from the PowerShell Gallery by runnign following command:

PS C:\> Install-Module AzureRM

NuGet provider is required to continue
PowerShellGet requires NuGet provider version ‘’ or newer to interact
with NuGet-based repositories. The NuGet provider must be available in
‘C:\Program Files\PackageManagement\ProviderAssemblies’ or
‘C:\Users\essensed\AppData\Local\PackageManagement\ProviderAssemblies’. You can
also install the NuGet provider by running ‘Install-PackageProvider -Name
NuGet -MinimumVersion -Force’. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is “Y”): Y

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this
repository, change its InstallationPolicy value by running the Set-PSRepository
cmdlet. Are you sure you want to install the modules from ‘PSGallery’?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is “N”):Y

On every prompt type ‘Y’ to proceed ahead.

While Installing the module you will see this screen:

5. Finally you just need to import the AzureRM module:

PS C:\> Import-Module AzureRM

This import command will not give any output, and you may proceed with the PS prompt.

Connect SQL Server on Linux with SSMS from a Windows machine

January 6, 2017 1 comment

In [previous post] we saw how to install & setup SQL Server on Linux. We used PuTTY to connect to the Linux Azure VM and query SQL Server there.

Here in this post we will try to connect to SQL Server on Linux via SSMS from a Windows machine.

So to connect remotely to SQL Server on an Azure VM, you have to configure an inbound rule on the network security group. The rule allows traffic on the port on which SQL Server listens (default is 1433).

–> Setup Inbound Rule:

1. You need to go to and login with your credentials. On the Dashboard you will see your Linux VM as shown below:


2. Click on the Linux VM widget, it will open up and list out the Settings, click on Network Interfaces, and select the available Network Interface from the list.


3. Now click on the Network Security Group:


4. On the Network Security Group page, select the Inbound security rules, and click on the “+” button create new for SQL Server:


5. On the Add inbound security rule page, provide a name to this rule, select “MS SQL” under Service drop-down, and click OK:


–> Connect using SSMS:

6. Now from any Remote machine or even you PC which has SSMS installed and have internet connection, try connecting the SQL Server Linux Instance:

– Server Name: provide the IP address of the Linux VM (you can get it by opening the “Linux VM widget” and clicking on “Connect” button at top)

– Authentication: should be SQL Server Authentication

– Login: “SA”

– Password: apply the same password that you set it up while Configuring SQL Server on Linux.


7. On successful authentication you will see the Object Explorer showing the SQL instance that’s running on a Linux machine. On a glance you can’t make out any difference b/w a Linux SQL instance or a Windows SQL instance.

Thus I executed the SELECT @@version statement which shows the SQL Server version and on which Operating system its running.

You can even see the Database SQLdbOnLinux that we created by connecting from the PuTTY client.


That’s it for now, will write more about SQL on Linux on coming updates from Microsoft !!!

–> You can also watch this on YouTube:

Install and Configure SQL Server 2017 on Linux Azure VM

January 4, 2017 2 comments


In my [previous blog] post we saw how to Create a new Linux VM on Azure. After creating it we connected it from a Windows workstation by using PuYYT tool and tested one Unix command.

Here in this post we will see how we can install SQL Server on Linux.

Microsoft is working on a new SQL Server vNext version that will work both on Windows as well as Linux. So with the recent [CTP 1.x] release we can see how does it look like on both the Operating Systems and get some hands on with it.

–> Get the Repository and Install SQL Server:

1. Import the public repository GPG keys:

curl | sudo apt-key add -

2. Register the Microsoft SQL Server Ubuntu repository:

curl | sudo tee /etc/apt/sources.list.d/mssql-server.list

3. Re-synchronize the Package index files from their sources, to get information of the newest versions of packages and their dependencies, and finally Install MSSQL-Server package:

sudo apt-get update
sudo apt-get install -y mssql-server

After Install it will ask you to run SQL Server setup by following message:

Please run /opt/mssql/bin/sqlservr-setup to complete the setup of Microsoft(R) SQL Server(R)

4. Now post install, we need to configure SQL Server and set the SA password, and SQL services.

sudo /opt/mssql/bin/sqlservr-setup

The Configuration gives following prompts in between:

Please enter a password for the system administrator (SA) account:
Please confirm the password for the system administrator (SA) account:

Setting system administrator (SA) account password…

Do you wish to start the SQL Server service now? [y/n]: y
Do you wish to enable SQL Server to start on boot? [y/n]: y

5. Post Configuration you can verify that the service is running:

systemctl status mssql-server


–> Install Tools: This will install the command-line tools (sqlcmd & BCP), Microsoft ODBC drivers, and their dependencies.

6. Re-synchronize the Package index files, and Install MSSQL-Tools:

curl | sudo apt-key add –
curl | sudo tee /etc/apt/sources.list.d/msprod.list

sudo apt-get update
sudo apt-get install mssql-tools unixodbc-dev

sudo ln -sfn /opt/mssql-tools/bin/sqlcmd- /usr/bin/sqlcmd
sudo ln -sfn /opt/mssql-tools/bin/bcp- /usr/bin/bcp


–> Connect to SQL instance:

9. We will use sqlcmd to connect to SQL Server vNext on our Linux VM. Run the sqlcmd command with following params:
– S: Server Name
– U: User Name
– P: Password

sqlcmd -S localhost -U SA -P ”


–> Run SQL Queries:

10. Now after connecting to the SQL Linux instance, let’s test come queries:

We will check the Version of SQL Server and list out system Databases:

select @@version

select database_id, name, create_date from sys.databases

Output of version statement:
Microsoft SQL Server vNext (CTP1.1) – (X64)
Dec 10 2016 02:51:11
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
on Linux (Ubuntu 16.04.1 LTS)

11. Let’s do more and Create a new Database, new Table and insert some sample records:


use SQLdbOnLinux
--Changed database context to 'SQLdbOnLinux'.
CREATE TABLE Test (i int, name varchar(25))
insert into Test values (1, 'Manoj')
insert into Test values (2, 'Saurabh')

--(1 rows affected)

--(1 rows affected)
select * from Test
--i           name
------------- -------------------------
--          1 Manoj
--          2 Saurabh

--(2 rows affected)

I think you would get amazed like me after using SQL Server on a Linux environment.

In my [next post] I’ll show how we can connect this SQL Linux instance from a Windows workstation via SSMS !!!

–> You can also watch this video on YouTube:

Spinning up a new Linux VM on Microsoft Azure

January 2, 2017 2 comments

First of all a very very Happy New Year to all of you !!!

This is my first blog post in 2017, and I’ll start with the most happening thing with SQL Server, which is SQL Server for Linux.

So today first of all we will see how to setup a Linux VM on Microsoft Azure cloud. And in next posts I’ve show how can we Install & Setup SQL Server on Linux.

I will use Ubuntu Server 16.04 LTS (Xenial Xerus) version from Azure Marketplace, and show how to setup a Linux VM in a step by step process.

All you need is a Microsoft Azure account, if you have not setup, please do it from here.

1. Go to and login with your credentials.

2. Click on the “+” icon, under “Marketplace” select Compute and under “Featured Apps” select Ubuntu Server.


3. The “Deployment Model” must be showing as Resource Manager by default, if not select form the drop-down list, and click on Create button.


4. Now on the Create virtual machine window, under “1. Basic” section provide:
– Name: new name for your Linux VM
– VM disk type: select Disk type, SSD or HDD
– User name: provide a unique user name for Admin purpose
– Authentication type: I selected “Password”
– Password & Confirm password
– Subscription: will show you your current subscription
– Resource Group: Provide a new name or select from the drop-down list
– Location: select location as per your preference and available in the list.
… and click OK.


5. On “2. Size” section Choose a size for your VM. I selected the DS1_v2 Standard, the cheapest one, finally click on Select button.


6. On 3. Settings section check the properties, I’ve left them as default for now, and click OK:


7. On the “4. Summary” section, the Portal will do various validations, just confirm all the settings and click OK.


8. And after few seconds or minutes your new Ubuntu Linux VM will be created and you can check the new widget appearing on your Dashboard as shown below:


9. Now to get the NIC (network Interface Card) or the User Name & IP address of your VM, click on the widget.

It will open a new window where you can check all the details related to your new Linux VM.

Just click the Connect button at the top which will show you the details so that you can connect via SSH or Telnet.


10. Now to connect the Linux VM you can either:

a. SSH directly from a Mac or Linux Terminal workstation.

b. Or, if you are on a Windows workstation, you need to use PuTTY, MobaXTerm or Cygwin to SSH to the Linux Azure VM.

Here, we will try connecting from a Windows workstation, so we will download PuTTY from

The downloaded PuTTY is a simple EXE application, just open it. Here we will provide the IP address that we saw above, you can copy and paste it as shown below and click Open:


11. This will open a PuTTY command shell window which will prompt you to enter the Linux username & password that you set in previous steps, please apply as shown below:


12. After you successfully logged in you will see some welcome message from Ubuntu with other details.

Just to make sure I’m really connected to a Linux command shell, I tried executing a Unix command “ls /” to list all the files & directories in the root drive.


So, this is how you can simply Create or Spin up a Linux VM in few minutes !!!

In my [next post] I’ll setup or install SQL Server vNext on this Linux VM and show you how can we connect via SSMS from a Windows workstation.

–> You can also watch this on YouTube: