Skip to main content

SQL Azure (Day 4 of 31)

List of all posts from this series: http://vunvulearadu.blogspot.ro/2014/11/azure-blog-post-marathon-is-ready-to.html

Short Description 
Azure SQL Database gives us the possibility to work with a database as a service. We don’t need to manage hardware, buy SQL license and things like that. The only thing that we need to focus on is the database content.
We will see later that there are features for backup, scaling and many more out of the box.

Main Features 
Scaling
In this moment there are types of service tiers that can be used

  • Basic
  • Standard 
  • Premium

Each tier had different performance levels that are starting from 5 DTU and can go up to 800 DTU. A DTU is Database Throughput Unit and is used to measure the performance of a database.
Database Size
You can start from small databases that have 2GB and you can go even to 500GB, with 1.6k threads in parallel and 19.2K open session.
High number of transactions
In this moment we can reach a maximum number of 735 transactions per seconds. Of course if you don’t need this performance you can go with the Basic tire where you can have around ~4-5 transactions per second.
Backup and export
We are allowed to create automatically backups of our database and store them in Azure Blobs. We can specify how often backups are created and the retention period.
Geo-Replication
Using this feature we can you can have in different regions a replica of your database that will be active (in read-only mode) in the case when the primary node status is shaky.

  • There are four types of replication model available on Azure SQL:
  • Point-in-time restore – Gives you the possibility to restore to a specific point in time (using backup features)
  • Geo-Restore – Similar with the above one, but the back-up is created in different region (this will assure you that if something goes bad in that region, you backup can be still access)
  • Standard geo-replication – You have a replica in a different region at in case something bad happens in the first region, the second one will be activated. In ‘idle’ you cannot access this database. Synchronization between this two tiers is made asyc.

Active Geo-Replication – Similar with the one above, but the synchronization is made faster and you can have maximum 4 nodes in different regions. On top of this you can access secondary nodes in read-only mode.
Audit
You can active the audit functionality and have a trace off all actions that happen on your database, from access time to what was change, permissions and security expectations. This information can be analyzed and reports can be created automatically.
Elastic Scale
Database can scale automatically up or down based on application needs. Behind you create multiple shards automatically, based on your needs. You can control the number of shards that are created.

SLA 99.99%
Yes! This is great, especially because usually when database is down all your application is also down. So, YES, 99.99%.
No Maintenance and system down because of updates
Because we are talking about SQL as a service, there is no concept of system down because of maintenance or updates.

Limitations 
There are some limitation because we use a SQL as a service. Because of this there are commands and actions that we cannot execute anymore.
RESTORE Command
This command is not supported, but we can restore database from portal of from power shell.
Attaching databases
Because we create a database we cannot attach one. As a work around we can create an empty database and restore a BACPAC.
SQL Jobs
In this moment there is no support for SQL Jobs, but future is blue.
Transaction Support
There is no support for distributed transactions
Cluster Index (Have to)
Each table has to have a cluster index. This is required before making the first insert to table.
User name restrictions
Some user names like: admin, administrator, guest, root, sa are restricted.
Connection idle time limit
The maximum idle connection time is 30 minutes.

Applicable Use Cases 
Below you can find 4 use cases when SQL Azure is best option for us.
Shared Database
When we have a data base that need to be shared between multiple organizations. Using SQL Azure we can very easily manage, access and control the database.
Startups 
When you have a startup is pretty hard to know how many users you will have, what the load will be. Using SQL Azure you can start from a small database and increase the power on it or decreased based on your needs. You will not need to spend money on licenses and hardware.
Peak Load
When you have an application that has from time to time peaks. You will pay only what you use and can scale automatically based on you needs (elastic scale). For the normal usage you can pay only what you need in that moment.
Geo-redundant
When you have data that needs to be available 99.99% of time and on top of this you cannot afford to lose data. Using SQL Azure you can have backups and replica in different location and you can switch to them when primary node is not stable anymore. The cost are less than implementing this by your own.

Code Sample 
By default SQL Azure don’t allow connection from any IP. You need to change this configuration from SQL Azure Firewall. This can be made very easily. There are two levels of firewalls, one at SQL Database level that allow or restrict access based on IP and another one where user can define custom rules like IP range or what database has access each IP.
The connection to SQL Azure is made same like for a normal SQL Server. There is no need for samples.

Pros and Cons
Pros

  • Stable
  • SDK is comprehensive and well documented
  • Very fast and fits into development workflow
  • Easy to scale
  • Ready for enterprise
  • Easy to port existing code
  • Backup support
  • Geo-Replication

Cons

  • No distributed cache
  • Some SQL features are not available
  • No support for large database (2TB for example, but future is BLUE or we can split them)


Pricing
Pricing is based on what kind of tier you use (Basic, Standard, Premium)
If you use backups, don’t forget that you will pay the space used by backups on blobs
Outbound traffic between SQL Azure and clients that are not in the same datacenter (if is applicable)

Conclusion
In this moment on all my projects on Azure, I’m using SQL Azure without any kind of problem. I would say that with Azure Storage are the best one.
Very fast, full with features and without uptime problems.

Comments

Popular posts from this blog

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

Run native .NET application in Docker (.NET Framework 4.6.2)

Scope
The main scope of this post is to see how we can run a legacy application written in .NET Framework in Docker.

Context
First of all, let’s define what is a legacy application in our context. By a legacy application we understand an application that runs .NET Framework 3.5 or higher in a production environment where we don’t have any more the people or documentation that would help us to understand what is happening behind the scene.
In this scenarios, you might want to migrate the current solution from a standard environment to Docker. There are many advantages for such a migration, like:

Continuous DeploymentTestingIsolationSecurity at container levelVersioning ControlEnvironment Standardization
Until now, we didn’t had the possibility to run a .NET application in Docker. With .NET Core, there was support for .NET Core in Docker, but migration from a full .NET framework to .NET Core can be costly and even impossible. Not only because of lack of features, but also because once you…