Azure SQL: Adding a new job is failing

Getting the below error

Inner Exception: “Object reference not set to an instance of an object.”
Stack Trace:
at System.Transactions.Transaction.GetPromotedToken()

The error comes from the line

connection.EnlistTransaction(Transaction.Current);

in below code even if i set enlist=false in the connection string.

internal T UseTransaction<T>([InstantHandle] Func<DbConnection, DbTransaction, T> func, IsolationLevel? isolationLevel)
  {
>             using (var transaction = CreateTransaction(isolationLevel ?? _options.TransactionIsolationLevel))
>             {
>                 var result = UseConnection(connection =>
>                 {
>                     connection.EnlistTransaction(Transaction.Current);
>                     return func(connection, null);
>                 });
>                 transaction.Complete();
>                 return result;
>             }
>     }

when we set enlist=true, then we get error at the line

connection.Open();

from the below code

internal DbConnection CreateAndOpenConnection()
        {
            if (_existingConnection != null)
            {
                return _existingConnection;
            }

            var connection = new SqlConnection(_connectionString);
            connection.Open();

            return connection;
        }

both the methods are present under Hangfire.SqlServer.SqlServerStorage class

Same code works when connected to the local DB (SQL server 2014).

Landed on a discussion c# - WCF Transaction against Azure SQL DB - Stack Overflow

not sure if it is relevant for this issue.

Please help.
Thanks in advance.

Found the issue. call to method to queue job was inside transaction which was somehow leading to Distribution Transaction and Azure SQL doesn’t support it.

Consider the code below:

        public override void UpdateFile(int intUniqueId)
        {
            using (var scope = GetTransactionScope(...))
            {
                 QueueJob<Updater>(x => x.Update(token, intUniqueId));
                scope.Complete();
            }
        }


        private static void QueueJob<T>(Expression<Action<T>> action)
        {
                BackgroundJob.Enqueue(action);
        }

Removing the transaction scope in callee method works.