How to reduce CreateTable transaction when use Azure function binding? - binding

Currently, my project is using Azure function 2.x.
I'm binding TableStorage to CloudTable. Function is triggered by Eventhub message
However, there are many CreateTable transactions. See picture below:
This transaction seem happens for every function invoke.
Check the source of in Github, that call the method: CreateIfNotExists() when binding, so I guess it can be the root cause of this behavior above. It is strange, too much CreateTable transactions does not happen in Azure function 1.x
Is there anyway to reduce CreateTable transaction?
May I need to use custom binding?
Thanks in advance.

There are many CreateTable transactions.
The reason why have so many CreateTable transactions is because the underlying code is trying to create.
Is there anyway to reduce CreateTable transaction? May I need to use
custom binding?
I am not sure what language you are using now, if you try to use C# IBinder, maybe you will still run the create step. You can create your own logic in the body of function, I think this can perfectly avoid this problem. Just try to get it instead of create it.

Related

ASP MVC - I need to periodically check my database, how can i do that?

I got an online website written in ASP.MVC. Now, i need to periodically check one table, and if it changes, i need to take further actions related with modifying data in other tables. I could of course write a stand-alone application that would do that for me, but what other options do i have? I am asking, because maybe there is something better which i don't know about.
Assuming that you're using SQL Server, one option would be to add an item to the ASP.NET Cache, and then register a SqlCacheDependency on that item for the table or row that is to be monitored. There is a bit of configuration required to get this up and running, some instructions are here (with the code samples being in VB). When you add the item to the cache that has a SqlCacheDependency, you can specify a callback method that is fired when the data changes, which is how you would update related tables. If you are running SQL Server, want a pre-defined solution provided by Microsoft, and don't mind the setup process and additional database tables and configuration that this includes, this would be a great option.
I got an answer that is satysfying my requirements. There is something called Quartz.net that works just as i wanted it to. :)

About grails In my office tell me about CRUD must be code in service why?

Today I have present about CRUD in grails When I show source code friend tell me it incorrect cause it's not code in service almost coding by use gen controller(this active record correct??)
why me code CRUD in service ?? I dont understand plz suggest me
Doing read only operations in a controller is ok. The reason write operations should be done in a service is because services are transactional by default. If you write to more than 1 table at a time in a controller, and one of them fails, you will have corrupt / incomplete data.
If you do the same in a transactional service, all changes rollback, which is what you want. While there might "centrality not a definite answer", this is common pattern/practice that goes even beyond Grails.

Grails pogo method calls within a transaction

This may be a dumb question.
I'm on a time constraint so I don't have much time to play with it, but if I call a pogo object's method residing in src/groovy from a grails service and it performs JDBC database work, will all of it be included within the current transaction? Or should I make these pogos into services?
Can't find the answer directly anywhere and don't have much time to experiment.
Thanks!
Once you're within a transaction, any GORM methods you call (directly or indirectly) from there will execute within that transaction unless the code makes a special effort to do something different (e.g. using its own withTransaction {} block).

Shouldn't Grails GORM calls be in the service and not controller layer?

I'm trying to decide, according to Grails best practices and MVC patterns, when is the correct time to introduce a Service and not keep fattening controllers. I find it somewhat conflicting, what I've read about best practices and what appears to be common practice, so would love to hear what others think about this.
With GORM calls in mind, I would have expected that anything to do with GORM should really go into a service. Although I don't practice this myself, especially when writing very basic controller methods like show that simply perform a get() on a domain class and then render a view to show the details of the retrieved object.
However, after following books like 'Clean Code' and similar books, well maintained code should be cohesive and methods should ideally perform a single task only. So in the perfect world, would the show method in a controller be responsible only for determining the object to display before rendering a view? The retrieval from the database could go into a method in the database that's sole task is to retrieve from the DB and throw an exception if not found etc.
But yes, this does somewhat seem like overkill.
So taking the step a bit further, the create() or update() methods. Again currently Grails' generated code puts everything into the controller, no use of a service at all.
So when would the recommended point be that we need to use a Service? Is it only when something transactional has to take place, for instance, on a create() call, we might also want to write a record to a Log file to keep an audit log of sorts. Surely this warrants a service?
I'd love to hear what others feel is the correct time to introduce services, I imagine it differs greatly person to person.
I recommend you this post: http://www.infoq.com/articles/grails-best-practices
We are creating static methods in Domain class to encapsulate queries. Service are used only for transactional operations or very complex queries with multiple domains interaction. Controllers simply call domains or services methods.

asp.net mvc LINQ TO SQL handling database events (alerts/feed)

Recently I did one web site (www.ramtajogi.com) using asp.net mvc, linq to sql .
I have used repository pattern to get data from the database. Now everything is working fine.
But the new requirement is to record all the events (on poetry book created, on poem added or when a new comment is posted to any poem. What is the best way to implement it.
Should I change my existing classes and do or is there any better way to do it.
Regards
Parminder
I think what you are looking for is a way to log across different actions:
Try this: http://www.singingeels.com/Articles/Logging_with_ASPNET_MVC_Action_Filters.aspx
Maybe you want to go the "SQL Trigger" road? I know it's a much debated subject, but it allows you to log without changing any of your existing code.
I'm not sure about its impact, but if the triggers only do some inserts into a log table, I guess it should be quite low.
Thanks everyone,
Actually I created another table for alerts and added one record for every event.
Regards
Parminder

Resources