title: Multiple processors trying to update the same row in database
body: <p>I have an Azure function app that triggers when data is enqueued to a service bus queue. In the Azure function, I implemented a charging method. First I get the particular row from the database and check the account points.</p>
  <p><code>SELECT * FROM UsersAccountPoints WHERE UserId = @UserId</code></p>
  <p>Then I update the points.</p>
  <pre><code>UPDATE UsersAccountPoints
  SET FundsChange = @ChargeAmount, FundsAmount -= @ChargeAmount
  WHERE UserId = @UserId
  </code></pre>
  <p>When I run this on local, it runs perfectly fine. But when I deploy it on Azure, the function app starts scaling. Then parallel processors start updating the same row of the UsersAccountPoints table, giving me confusing results.</p>
  <p>Then I tried <code>UPDLOCK</code>.</p>
  <pre><code>SELECT *
  FROM UsersAccountPoints WITH (UPDLOCK)
  WHERE UserId = @UserId
  </code></pre>
  <p>But this also gives me the same result. I use the Azure premium function, SQL Server database, and Dapper for ORM. Is there a better way to handle this kind of scenario than <code>UPDLOCK</code>?</p>