Breaking news from around the world
Get the Bing + MSN extension
Now Available in Community - MBAS 2019 Presentation Videos
Catch the most popular sessions on demand and learn how Dynamics 365, Power BI, PowerApps, Microsoft Flow, and Excel are powering major transformations around the globe. | View Gallery
2019 release wave 2 Discover the latest updates to Dynamics 365Release overview guides and videos Release Plan | Early Access Availability
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Talent TechTalks | Upcoming TechTalks
In these series of Platform Runtime posts, we will be offering some best practices, recommendations and guidelines to assist you in optimizing your code for a better reliable experience.
In the Cloud World Today, there are several things to consider because of the way Azure cloud Works. In this topic will talk about the usage of UserConnection with Azure SNAT Pool.
Azure uses source network address translation (SNAT) to communicate with endpoints outside Azure,
When an instance initiates an outbound flow to a destination in the public IP address space, Azure dynamically maps the private IP address to a public IP address.
The SNAT ports are a finite resource, the pre-allocation size is pre-defined for SNAT Pool. If the ports get used, the next request will be throttled.
UserConnection is the class to create the SQL Connection from D365 Fin&Ops. The Connection is running on the physical networking connection with SNAT port assigned, which means the max number of connections is limited by the pool and not only by SQL.
Once the SNAT Pool is exhausted, the request to setup SQL Connection will be dropped.
Let’s Examine the following code,
Can you find something wrong here ?
Let’s compare the results from SQL system table of sys.dm_exec_sessions.
The UserConnection is still holding the connection of 56 even after the call of the InsertData().
Wait.... UserConnection is a managed object, why not delete it? Because Garbage Collector won’t free the resources instantaneously even if the object is out of scope. If InsertData() is a very popular function, it may be called very often, which will definitely lead to the SNAT Pool exhaustion and no more AOS Session allocated.
When the UserConnection is the only choice for you, we strongly suggest to call finalize() to close the Connection.
Here is the Good Sample,
By Using the finalize() will efficiently use the UserConnection and will reduce the possibility for the application to run out of connections.
There is no different b/w A and B. XPP compiler will set conn as null if conn is not explicitly assigned as null.
Thanks for the tip, sound like good practice to end with finalise.
Can we write "userConnection = null;"? Will it be the same?
Business Applications communities