Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Azure/azure-content-pr in…
Browse files Browse the repository at this point in the history
…to adc-ga
  • Loading branch information
steelanddata committed Mar 30, 2016
2 parents 89e56e2 + 6207b68 commit 36ddb7f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 39 deletions.
75 changes: 45 additions & 30 deletions articles/sql-database/sql-database-connectivity-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ms.tgt_pltfrm="na"
ms.devlang="na"
ms.topic="article"
ms.date="02/17/2016"
ms.date="03/30/2016"
ms.author="daleche"/>


Expand All @@ -26,11 +26,13 @@ This article describes how to prevent, troubleshoot, diagnose, and mitigate conn

## Transient errors (transient faults)

A transient error - also, transient fault - has an underlying cause that will soon resolve itself. An occasional cause of transient errors is when the Azure system quickly shifts hardware resources to better load-balance various workloads. During this reconfiguration time span, you may have connectivity issues to Azure SQL Database.
A transient error - also, transient fault - has an underlying cause that will soon resolve itself. An occasional cause of transient errors is when the Azure system quickly shifts hardware resources to better load-balance various workloads. Most of these reconfiguration events often complete in less than 60 seconds. During this reconfiguration time span, you may have connectivity issues to Azure SQL Database. Applications connecting to Azure SQL Database should be built to expect these transient errors, handle them by implementing retry logic in their code instead of surfacing them to users as application errors.

If your client program is using ADO.NET, your program is told about the transient error by the throw of an **SqlException**. The **Number** property can be compared against the list of transient errors near the top of the topic:
[SQL error codes for SQL Database client applications](sql-database-develop-error-messages.md).

<a id="connection-versus-command" name="connection-versus-command"></a>

### Connection versus command

You'll retry the SQL connection or establish it again, depending on the following:
Expand All @@ -42,16 +44,17 @@ You'll retry the SQL connection or establish it again, depending on the followin

<a id="j-retry-logic-transient-faults" name="j-retry-logic-transient-faults"></a>

## Retry logic for transient errors
### Retry logic for transient errors


Client programs that occasionally encounter a transient error are more robust when they contain retry logic.


When your program communicates with Azure SQL Database through a 3rd party middleware, inquire with the vendor whether the middleware contains retry logic for transient errors.

<a id="principles-for-retry" name="principles-for-retry"></a>

### Principles for retry
#### Principles for retry


- An attempt to open a connection should be retried if the error is transient.
Expand All @@ -75,7 +78,7 @@ When your program communicates with Azure SQL Database through a 3rd party middl
- However, the solution must not be to retry every few seconds, because that policy can flood the system with requests.


### Interval increase between retries
#### Interval increase between retries



Expand All @@ -86,7 +89,7 @@ A discussion of the *blocking period* for clients that use ADO.NET is available
You might also want to set a maximum number of retries before the program self-terminates.


### Code samples with retry logic
#### Code samples with retry logic


Code samples with retry logic, in a variety of programming languages, are available at:
Expand All @@ -96,13 +99,13 @@ Code samples with retry logic, in a variety of programming languages, are availa

<a id="k-test-retry-logic" name="k-test-retry-logic"></a>

## Test your retry logic
#### Test your retry logic


To test your retry logic, you must simulate or cause an error than can be corrected while your program is still running.


### Test by disconnecting from the network
##### Test by disconnecting from the network


One way you can test your retry logic is to disconnect your client computer from the network while the program is running. The error will be:
Expand All @@ -124,7 +127,7 @@ To make this practical, you unplug your computer from the network before you sta
5. Attempt again to connect, expecting success.


### Test by misspelling the database name when connecting
##### Test by misspelling the database name when connecting


Your program can purposely misspell the user name before the first connection attempt. The error will be:
Expand All @@ -144,18 +147,7 @@ To make this practical, your program could recognize a run time parameter that c
4. Remove 'WRONG_' from the user name.
5. Attempt again to connect, expecting success.


<a id="a-connection-connection-string" name="a-connection-connection-string"></a>

## Connection: Connection string


The connection string necessary for connecting to Azure SQL Database is slightly different from the string for connecting to Microsoft SQL Server. You can copy the connection string for your database from the [Azure Portal](https://portal.azure.com/).


[AZURE.INCLUDE [sql-database-include-connection-string-20-portalshots](../../includes/sql-database-include-connection-string-20-portalshots.md)]


<a id="net-sqlconnection-parameters-for-connection-retry" name="net-sqlconnection-parameters-for-connection-retry"></a>

### .NET SqlConnection parameters for connection retry

Expand All @@ -181,8 +173,9 @@ Specifically, your chosen values should make the following equality true:

For example, if the count = 3, and interval = 10 seconds, a timeout of only 29 seconds would not quite give the system enough time for its 3rd and final retry at connecting: 29 < 3 * 10.

<a id="connection-versus-command" name="connection-versus-command"></a>

#### Connection versus command
### Connection versus command


The **ConnectRetryCount** and **ConnectRetryInterval** parameters let your **SqlConnection** object retry the connect operation without telling or bothering your program, such as returning control to your program. The retries can occur in the following situations:
Expand All @@ -197,11 +190,24 @@ There is a subtlety. If a transient error occurs while your *query* is being exe

Suppose your application has robust custom retry logic. It might retry the connect operation 4 times. If you add **ConnectRetryInterval** and **ConnectRetryCount** =3 to your connection string, you will increase the retry count to 4 * 3 = 12 retries. You might not intend such a high number of retries.

<a id="a-connection-connection-string" name="a-connection-connection-string"></a>

## Connections to Azure SQL Database

<a id="c-connection-string" name="c-connection-string"></a>

### Connection: Connection string


The connection string necessary for connecting to Azure SQL Database is slightly different from the string for connecting to Microsoft SQL Server. You can copy the connection string for your database from the [Azure Portal](https://portal.azure.com/).


[AZURE.INCLUDE [sql-database-include-connection-string-20-portalshots](../../includes/sql-database-include-connection-string-20-portalshots.md)]


<a id="b-connection-ip-address" name="b-connection-ip-address"></a>

## Connection: IP address
### Connection: IP address


You must configure the SQL Database server to accept communication from the IP address of the computer that hosts your client program. You do this by editing the firewall settings through the [Azure Portal](https://portal.azure.com/).
Expand All @@ -219,7 +225,7 @@ For more information, see:

<a id="c-connection-ports" name="c-connection-ports"></a>

## Connection: Ports
### Connection: Ports


Typically you only need to ensure that port 1433 is open for outbound communication, on the computer that hosts you client program.
Expand All @@ -246,7 +252,7 @@ For background information about cofiguration of ports and IP address, see:

<a id="d-connection-ado-net-4-5" name="d-connection-ado-net-4-5"></a>

## Connection: ADO.NET 4.6.1
### Connection: ADO.NET 4.6.1


If your program uses ADO.NET classes like **System.Data.SqlClient.SqlConnection** to connect to Azure SQL Database, we recommend that you use .NET Framework version 4.6.1 or higher.
Expand All @@ -269,7 +275,11 @@ If you are using ADO.NET 4.0 or earlier, we recommend that you upgrade to the la

<a id="e-diagnostics-test-utilities-connect" name="e-diagnostics-test-utilities-connect"></a>

## Diagnostics: Test whether utilities can connect
## Diagnostics

<a id="d-test-whether-utilities-can-connect" name="d-test-whether-utilities-can-connect"></a>

### Diagnostics: Test whether utilities can connect


If your program is failing to connect to Azure SQL Database, one diagnostic option is to try to connect with a utility program. Ideally the utility would connect by using the same library that your program uses.
Expand All @@ -286,7 +296,7 @@ Once connected, test whether a short SQL SELECT query works.

<a id="f-diagnostics-check-open-ports" name="f-diagnostics-check-open-ports"></a>

## Diagnostics: Check the open ports
### Diagnostics: Check the open ports


Suppose you suspect that connection attempts are failing due to port issues. On your computer you can run a utility that reports on the port configurations.
Expand Down Expand Up @@ -322,7 +332,7 @@ TCP port 1433 (ms-sql-s service): LISTENING

<a id="g-diagnostics-log-your-errors" name="g-diagnostics-log-your-errors"></a>

## Diagnostics: Log your errors
### Diagnostics: Log your errors


An intermittent problem is sometimes best diagnosed by detection of a general pattern over days or weeks.
Expand All @@ -338,7 +348,7 @@ Enterprise Library 6 (EntLib60) offers .NET managed classes to assist with loggi

<a id="h-diagnostics-examine-logs-errors" name="h-diagnostics-examine-logs-errors"></a>

## Diagnostics: Examine system logs for errors
### Diagnostics: Examine system logs for errors


Here are some Transact-SQL SELECT statements that query logs of error and other information.
Expand All @@ -349,6 +359,7 @@ Here are some Transact-SQL SELECT statements that query logs of error and other
| `SELECT e.*`<br/>`FROM sys.event_log AS e`<br/>`WHERE e.database_name = 'myDbName'`<br/>`AND e.event_category = 'connectivity'`<br/>`AND 2 >= DateDiff`<br/>&nbsp;&nbsp;`(hour, e.end_time, GetUtcDate())`<br/>`ORDER BY e.event_category,`<br/>&nbsp;&nbsp;`e.event_type, e.end_time;` | The [sys.event_log](http://msdn.microsoft.com/library/dn270018.aspx) view offers information about individual events, including some that can cause transient errors or connectivity failures.<br/><br/>Ideally you can correlate the **start_time** or **end_time** values with information about when your client program experienced problems.<br/><br/>**TIP:** You must connect to the **master** database to run this. |
| `SELECT c.*`<br/>`FROM sys.database_connection_stats AS c`<br/>`WHERE c.database_name = 'myDbName'`<br/>`AND 24 >= DateDiff`<br/>&nbsp;&nbsp;`(hour, c.end_time, GetUtcDate())`<br/>`ORDER BY c.end_time;` | The [sys.database_connection_stats](http://msdn.microsoft.com/library/dn269986.aspx) view offers aggregated counts of event types, for additional diagnostics.<br/><br/>**TIP:** You must connect to the **master** database to run this. |

<a id="d-search-for-problem-events-in-the-sql-database-log" name="d-search-for-problem-events-in-the-sql-database-log"></a>

### Diagnostics: Search for problem events in the SQL Database log

Expand Down Expand Up @@ -417,6 +428,7 @@ A short C# code sample that uses EntLib60 in its retry logic is available at:

> [AZURE.NOTE] The source code for EntLib60 is available for public [download](http://go.microsoft.com/fwlink/p/?LinkID=290898). Microsoft has no plans to make further feature updates or maintenance updates to EntLib.
<a id="entlib60-classes-for-transient-errors-and-retry" name="entlib60-classes-for-transient-errors-and-retry"></a>

### EntLib60 classes for transient errors and retry

Expand Down Expand Up @@ -454,6 +466,7 @@ Here are links to information about EntLib60:

- NuGet download of [Enterprise Library - Transient Fault Handling application block 6.0](http://www.nuget.org/packages/EnterpriseLibrary.TransientFaultHandling/)

<a id="entlib60-the-logging-block" name="entlib60-the-logging-block"></a>

### EntLib60: The logging block

Expand All @@ -470,6 +483,7 @@ Here are links to information about EntLib60:
For details see:
[5 - As Easy As Falling Off a Log: Using the Logging Application Block](https://msdn.microsoft.com/library/dn440731%28v=pandp.60%29.aspx)

<a id="entlib60-istransient-method-source-code" name="entlib60-istransient-method-source-code"></a>

### EntLib60 IsTransient method source code

Expand Down Expand Up @@ -546,8 +560,9 @@ public bool IsTransient(Exception ex)
```


## More information
## Next steps

- For troubleshooting other common Azure SQL Database connection issues, visit [Troubleshoot common connection issues to Azure SQL Database](sql-database-troubleshoot-common-connection-issues.md).

- [SQL Server Connection Pooling (ADO.NET)](http://msdn.microsoft.com/library/8xx3tyca.aspx)

Expand Down
24 changes: 15 additions & 9 deletions includes/sql-database-include-ip-address-22-v12portal.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
includes/sql-database-include-ip-address-22-v12portal.md
Latest Freshness check: 2015-09-04 , GeneMi.
Latest Freshness check: 2016-03-21 , daleche.
As of circa 2015-09-04, the following topics might include this include:
articles/sql-database/sql-database-configure-firewall-settings.md
Expand All @@ -17,26 +17,32 @@ articles/sql-database/sql-database-connect-query.md

1. Log in to the [Azure portal](https://portal.azure.com/) at http://portal.azure.com/.

2. In the left banner, click **Browse**. The **Browse** blade is displayed.
2. In the left banner, click **BROWSE ALL**. The **Browse** blade is displayed.

3. Scroll and click **SQL servers**. The **SQL servers** blade is displayed.
3. Scroll and click **SQL servers**. The **SQL servers** blade is displayed.

![Find your Azure SQL Database server in the portal][b21-FindServerInPortal]

4. Click the row for your server. A blade for your server is displayed.
4. For convenience, click the minimize control on the earlier **Browse** blade.

5. On your server blade, click **Settings**. The **Settings** blade is displayed.
5. In the filter text box, start typing the name of your server. Your row is displayed.

6. Click **Firewall**. The **Firewall Settings** blade is displayed.
6. Click the row for your server. A blade for your server is displayed.

7. On your server blade, click **Settings**. The **Settings** blade is displayed.

8. Click **Firewall**. The **Firewall Settings** blade is displayed.

![Click Settings > Firewall][b31-SettingsFirewallNavig]

7. Click **Add Client IP** to add the IP address of your client computer. The portal will construct a name for your rule.
Or you can type in a name and provide the low and high IP address values for the range you want to enable. It can be handy to have the low value end with **.0** and the high with **.255**.
9. Click **Add Client IP**. Type in a name for your new rule into the first text box.

10. Type in the low and high IP address values for the range you want to enable.
- It can be handy to have the low value end with **.0** and the high with **.255**.

![Add an IP address range to allow][b41-AddRange]

8. Click **Save**.
11. Click **Save**.



Expand Down

0 comments on commit 36ddb7f

Please sign in to comment.