Exam-Answer

Home / Microsoft / AZ-300 / Question 125

Prev Question
Next Question

Question 125

Your company has a mobile app that accesses an Azure SQL Database. You want to ensure that the app is developed to handle temporary Azure service interruptions due to connectivity issues. You must ensure that whenever a connection fails, a new attempt is made, up to four times. A variable named connectionString represents the connection string to Azure SQL Database.

You need to complete the code.

How should you complete the code? Select correct placeholder values.

var x = PLACEHOLDER 1;

using (var conn = new PLACEHOLDER 2(PLACEHOLDER 3))

{

conn.Open();

}

Answers



A B C D E F

Advertisement

Explanation

You should use the following code:

var x = new RetryPolicy<SqlDatabaseTransientErrorDetectionStrategy>(4);

using (var conn = new ReliableSqlConnection(connectionString, x))

{

conn.Open();

}

The first statement creates a RetryPolicy instance that represents how retries should occur in the event of a connection failure. The class accepts a generic type parameter that specifies the transient detection strategy. In this scenario, it specifies the SqlDatabaseTransientErrorDetectionStrategy class. The constructor accepts a parameter that specifies the number of retries, which is four in this scenario.

The next statement creates an instance of ReliableSqlConnection, passing to it the connection string and the RetryPolicy instance. This represents a connection to the database with the retry policy.

You should not set the variable x to 4. You should set this to a RetryPolicy instance.

You should not create an instance of SqlConnection. This class does not support retry policies.

References

Comments

Load more
Prev Question
Next Question