I am new to Azure and SQL.  I have the following function that is part of a larger Web-API which is hosted on Azure and is querying an SQL Server database that is also hosted on the Azure platform:[WebMethod]public string RetrieveUserFriends(string userId){    //Ensure there is a user id    if (userId == null)    {        return UserId is missing.;    }    //Build the Connection String    System.Data.SqlClient.SqlConnectionStringBuilder builder = BuildConnection();    //Build the query    string query = string.Format(SELECT  u2.UserId, u2.[first name], u2.[last name], u2.[username] FROM       Users u1 INNER JOIN Friends f1 ON u1.userid = f1.userid INNER JOIN Users u2 ON u2.userid = f1.FriendId INNER JOIN Friends f2 ON u2.userid = f2.friendid WHERE   ( f2.userid = '{0}'    OR f1.friendid = '{0}') AND u2.userid != '{0}';, userId);    try    {        //1. Define an Exponential Backoff retry strategy for Azure SQL Database throttling (ExponentialBackoff Class). An exponential back-off strategy will gracefully back off the load on the service.        int retryCount = 4;        int minBackoffDelayMilliseconds = 2000;        int maxBackoffDelayMilliseconds = 8000;        int deltaBackoffMilliseconds = 2000;        ExponentialBackoff exponentialBackoffStrategy =          new ExponentialBackoff(exponentialBackoffStrategy,              retryCount,              TimeSpan.FromMilliseconds(minBackoffDelayMilliseconds),              TimeSpan.FromMilliseconds(maxBackoffDelayMilliseconds),              TimeSpan.FromMilliseconds(deltaBackoffMilliseconds));        //2. Set a default strategy to Exponential Backoff.        RetryManager manager = new RetryManager(new List<RetryStrategy>{  exponentialBackoffStrategy }, exponentialBackoffStrategy);        //3. Set a default Retry Manager. A RetryManager provides retry functionality, or if you are using declarative configuration, you can invoke the RetryPolicyFactory.CreateDefault        RetryManager.SetDefault(manager, false);        //4. Define a default SQL Connection retry policy and SQL Command retry policy. A policy provides a retry mechanism for unreliable actions and transient conditions.        RetryPolicy retryConnectionPolicy = manager.GetDefaultSqlConnectionRetryPolicy();        RetryPolicy retryCommandPolicy = manager.GetDefaultSqlCommandRetryPolicy();        string json = string.Empty;        //5. Create a function that will retry the connection using a ReliableSqlConnection.        retryConnectionPolicy.ExecuteAction(() =>        {            using (ReliableSqlConnection connection = new ReliableSqlConnection(builder.ConnectionString))            {                connection.Open();                IDbCommand command = connection.CreateCommand();                command.CommandText = query;                //6. Create a function that will retry the command calling ExecuteCommand() from the ReliableSqlConnection                retryCommandPolicy.ExecuteAction(() =>                {                    using (IDataReader reader = connection.ExecuteCommand<IDataReader>(command))                    {                        List<GameOnUser> users = new List<GameOnUser>();                        int count = reader.FieldCount;                        while (reader.Read())                        {                            GameOnUser user = new GameOnUser();                            for (int i = 0; i < count; i++)                            {                                if (i == 0)                                {                                    user.ID = reader.GetGuid(i).ToString();                                }                                else if (i == 3)                                {                                    user.Username = reader.GetString(i);                                }                            }                            users.Add(user);                        }                        json = new JavaScriptSerializer().Serialize(users);                    }                });            }        });        return json;    }    catch (Exception e)    {        return ERROR (RetrieveUserFriends):  + e.Message;    }}NOTE: I am aware of the poorly named columns.  We intend to fix these in the near future.My main concern lies in the area of the returning JSON:string json = string.Empty;            //5. Create a function that will retry the connection using a ReliableSqlConnection.            retryConnectionPolicy.ExecuteAction(() =>            {                using (ReliableSqlConnection connection = new ReliableSqlConnection(builder.ConnectionString))                {                    connection.Open();                    IDbCommand command = connection.CreateCommand();                    command.CommandText = query;                    //6. Create a function that will retry the command calling ExecuteCommand() from the ReliableSqlConnection                    retryCommandPolicy.ExecuteAction(() =>                    {                        using (IDataReader reader = connection.ExecuteCommand<IDataReader>(command))                        {                            List<GameOnUser> users = new List<GameOnUser>();                            int count = reader.FieldCount;                            while (reader.Read())                            {                                GameOnUser user = new GameOnUser();                                for (int i = 0; i < count; i++)                                {                                    if (i == 0)                                    {                                        user.ID = reader.GetGuid(i).ToString();                                    }                                    else if (i == 3)                                    {                                        user.Username = reader.GetString(i);                                    }                                }                                users.Add(user);                            }                            json = new JavaScriptSerializer().Serialize(users);                        }                    });                }            });            return json;I have a feeling that it is prone to failure but I may be wrong. Any advice on this chunk would be much appreciated.
Users and friends query with retry, returning JSON
c#;performance;error handling;database;azure