Tuesday 31 January 2017

SQL Server : DB mirroring - Mirrored Database Disconnected

Issue
Recently I came across with an issue in High Performance Database Mirroring setup where mirror database status is showing Disconnected. This was happened due to network issue at particular location in the data centre last night. After once the issue was resolved I have checked the mirrored database status was showing Disconnected.

Resolution
There are two ways to resolve this issue. If the first method does not resolve the issue, use the second method.

Method 1
Recycle the endpoint on the database mirror. To do this, follow these steps:
On the principal database, execute the following SQL script to stop the endpoint:
    ALTER ENDPOINT  STATE=STOPPED
Execute the following SQL script to restart the endpoint:
    ALTER ENDPOINT  STATE=STARTED
Note : If communication between the endpoints does not restart after you execute the scripts, execute the scripts on the database mirror. However, the database may enter a "Suspended" state after you do this. If this issue occurs, execute the following SQL script:
ALTER DATABASE  SET PARTNER RESUME
Method 2
Delete and re-create the database mirroring endpoints on both servers.

In the conclusion, this generally happens because of problems in the SQL Server database mirroring endpoints.

Wednesday 25 January 2017

MS Azure : Log in and Log out to Azure from the Azure CLI

Log in to Azure


Scenario 1: Azure login with interactive Login
Interactive login is easy: type azure login -- without any options -- as shown in the following example:
azure login
The output appears something like the following:

info:    Executing command login
info:    To sign in, use a web browser to open the page http://aka.ms/devicelogin.
Enter the code XXXXX to authenticate.



Copy the code offered to you in the command output, and open a browser to http://aka.ms/devicelogin, or other page if specified. (You can open a browser on the same computer, or on a different computer or device.) Enter the code, and then you are prompted to enter the username and password for the identity you want to use.


When that process completes, the command shell completes the login. It might look something like:

info:    Added subscription Visual Studio Ultimate with MSDN
info:    Added subscription Azure Free Trial
info:    Setting subscription "Visual Studio Ultimate with MSDN" as default
+
info:    login command OK



Note: With interactive login, authentication and authorization are performed using Azure Active Directory. If you use a Microsoft account identity, the login process accesses your Azure Active Directory default domain. (If you signed up for a free Azure account, Azure Active Directory automatically created a default domain for your account.)

Scenario 2: azure login with a username and password
Use the azure login command with the username (-u) parameter to authenticate when you want to use a work or school account that doesn't require multifactor authentication. You are prompted at the command line for the password (or you can optionally pass the password as an additional parameter of the azure login command). The following example passes the username of an organizational account:
azure login -u Username@mysite.microsoft.com

You are then prompted to enter your password:
info:    Executing command login
Password: *********

The login process then completes.
info:    Added subscription Visual Studio Ultimate with MSDN
+
info:    login command OK

If this is your first time logging in with these credentials, you are asked to verify that you wish to cache an authentication token. This prompt also occurs if you previously used the azure logout command (described later in the article). To bypass this prompt for automation scenarios, run azure login with the -q parameter.

Once you are connected, enter azure it will take you to azure welcome screen as below:

Log out from Azure


To log out, use the following command:
azure logout -u