When a Resource Event Occurs Logic App Triggered Twice - azure-logic-apps

I've created a Logic App triggered when a resource event occurs, but it's triggered twice for each blob created.
Logic App details:
Trigger type: When a resource event occurs
Subscription: abc
Resource Type: Microsoft.Storage.StorageAccounts
Resource Name: abcxyz
Event Type Item - 1: Microsoft.Storage.BlobCreated
Prefix Filter: /blobserv/default/subfold
Suffix Filter: .pdf
From what I can find online, an event is fired when writing to blob is initiated, and another event is fired when the writing has been completed. This would explain the Logic App being triggered twice.
I tried to update the Logic App to filter on blob size, but it appears to be the same value for both triggered runs.
Get Blob Metadata using path (v2):
Size: 41556
So, is there a way to know if the Logic App is firing off the creation or completion event or another way to filter out the creation trigger?

I might have narrowed down your issue.
Every Put Blob Container Operation triggers two events (Started and Succeeded)
| Operation name | Status |
| Put blob Container | Succeeded |
| Put blob Container | Started |
Adding filter at Logic app level
Operation name == Put Blob Container
and
Status == Succeeded
should address your concern

Related

How to achieve a snappy, cascading UX via AngularJS + ui-router

root
/ | \
/ | \
/ | \
header content navbar
|
|
library (abstract)
/ | \
/ | \
/ | \
Authors Books Movies
Using my beautiful graphic above I would like to explain a few things:
header has some API data to retrieve about the user (e.g. GET /user/me)
Authors has its own GET /authors it uses to populate that view
Books and Movies are the same as Authors, they are just their own state
Now this is what I want:
I want a cascading layout whereby the main layout of the page can be loaded first, then the "library" application can be loaded on top of it without any "lag" or blocking of the UX.
However, with how ui-router seems to work today, if I have 1 resolve in this entire application and I place it in the "library" state, what happens is the "header" and "navbar" states are blocked until the resolve completes. What I would expect to happen is the parent states load first with their views, then the "library" state blocks on the resolve. That way you could see the navbar and header in the browser as soon as the page is loaded, but you would get a loading bar or spinner until the "library" resolve finished.
Any easy way to achieve this functionality would be to not use resolves and instead just have all the API logic inside the controller, however this causes the scope of each of the 3 resources to be limited to their controller and that is it. Meaning, if you are in the Movies controller, you have no visibility into the Authors resources because Authors are scoped to only the "Authors" controller. This makes things like web sockets less efficient and even unusable.
Am I doing something wrong here which is causing me to not get the desired functionality or is this not possible with this kind of architecture?

Trigger Google Analytics pageview for Angular App while using Google Tag Manager

I am building a SPA using Angular.js. We use Google Tag Manager to load in most of our analytics/marketing scripts, which includes Google Analytics. I am also using ui-router to manage states/views.
I would like to send pageview events off to Google Analytics whenever a user browses to a different state in my app. Part of the complexity in doing this with GTM is that GTM creates a named tracker. That means that all GA events need be prepended with the tracker name. That would usually look like this:
ga('trackerName.send', 'pageview', {page: '/a/path/', title: 'A Title'});
GTM uses a randomly generated tracker name, so the tracker name needs to be grabbed at runtime. That can be done fairly simply with GA's getAll function. If you want to send the pageview event to all trackers, you would simply do:
var allTrackers = ga.getAll();
for(var i=0; i<allTrackers.length; i++) {
ga.send(allTrackers[i].getName()+".send", "pageview", {page: '/a/path', title: 'A Title'});
}
This works great for most of my pageview events. However, there is a race condition between when ui-router fires the initial view's $stateChangeSuccess (which is where I trigger the GA pageview), and when analytics.js is loaded.
Prior to analytics.js being loaded, Google Analytic's snippet creates a faux ga object, that you can send events to. This faux object does not have the rest of the ga functions on it, so you can not run getAll. Without the getAll function, I cannot get the tracker name and I cannot send pageview events.
As far as I can tell, Google Analytics does not provide any callbacks or events for when analytics.js is finished loading, so there is no way to tell when I will be able to start sending events. Right now I am using an $interval to check for the existence of ga.getAll, but that is not a very performant or ideal solution. This is what I've got:
gaCheckInterval = setInterval(function() {
if(typeof(ga) !== 'undefined' && typeof(ga.getAll) == 'function') {
clearInterval(gaCheckInterval);
sendBackloggedEvents();
}
}, 200);
Is there any other way to recognize when analytics.js has finished loading? Or any other way to send events to a named tracker, without having access to getAll?
Attempting to configure and trigger individual trackers circumvents the purpose of using a tag manager. Instead do:
dataLayer.push({event:'spa.pageView', page:..., title:...});
Where:
dataLayer is optionally renamed in the gtm snippet
spa is a handy abbreviation for your app/project/company/whatever in case you need to distinguish its actions later.
page and title can be whatever you like, you will reference them by adding dataLayer macros in your GTM container.
Then, in the tag manager you configure:
rule of {{event}} ends with pageView.
dataLayer macros for the page, title you are pushing into the dataLayer.
UA Tag (and later whatever else) to fire (1) and use the macros in (2) for the TAG parameters they override.
Repeat (3) as many times as you like for different UA properties with additional blocking rules, alternate macros or more granular firing rules as necessary.
Now you can configure the specifics and add other tag types that reuse the rules and macros without modifying the application for each change.

Angular JS filters using Firebase data

I have some data in firebase that looks like this:
|
|
--users
|
--1
|
--email:"hello#gmail.com"
--name:"User 01"
--2
|
--email:"hello2#gmail.com"
--name:"User 02"
--chat
|
---JU9ZpBj7P9dWgNYN4To
|
--email:"hello#gmail.com"
--content:"Hi, i'm user 01! How are you?"
--user:"1"
--timestamp:"123456789"
---JX8ZpBnli7hliwehlfi
|
--email:"hello2#gmail.com"
--content:"Hi, i'm user 02! I'm great thanks!"
--user:"2"
--timestamp:"123456789"
I get the chat data from firebase in an object called 'messages', and my HTML/angular looks like this:
<ul class="chat" ng-repeat="message in messages | orderByPriority | reverse">
<li>
<strong>{{message.user | uid2name}}</strong> {{message.content}}
</li>
</ul>
So what I want to do is grab message.user and convert it from a userid into a name. I figured a good way would be to use a filter:
.filter('uid2name', function(loginService, $rootScope) {
// Takes a userid and outputs a users name
return function(input) {
var ref = new Firebase('https://<myapp>.firebaseio.com/users/' + input);
return $firebase(ref).name;
};
})
Now this works fine, but it does so by essentially polling firebase multiple times per second - not what I want to do at all. I have thought about caching the response in $rootScope but this seems a bit sloppy. What's the best way going about this? I am open to any ideas, I am not wed to the idea of using a filter.
Filters are one the things I love a bout Angular, but they are too heavy (since they are evaluated with every digest cycle) and definitely does't suite to your approach, unless you use cache (just don't store it in $rootScope, create a cache service instead).
Firebase is all about performance, in most cases normalization is your enemy. You already store user email, why don't you also store user name as well?
Changing the data structure to include userId in the URL of your Chat data structure may help: Data Modeling Best Practices in Firebase/AngularFire
In the end, I solved this problem by using the angular-cache plugin (the default angular cache-factory is good but it lacks a few useful features). I cached the users in order to use a filter without hammering firebase.

how to do auto fetch in backbone

I have a collection of models I fetch from a REST API every 10 seconds. (collection.fetch() every 10 seconds with a timer).
The user can also edit the model in a dialog box and click Save going back to the table of models.
How do I prevent cases where the user saves a model in a dialog and the auto fetch exactly comes back with a stale model so the model stays with the stale data until the next auto fetch.
Two suggestions:
Use collection.fetch({ update: true }) - that way models will only be add/remove/change'd rather than recreated on each fetch.
When the model is edited via the your dialog box, only save() the specific attributes that the user changed, like model.save(changedData, { patch: true }); -- using this patch behavior will make sure you're only sending the attributes that were just changed. Then your server can respond with the other recently-changed attributes, and all should be fine.

Show custom pop up warning message when user changes any value (text box/LOV) on page

I have requirement to show custom pop up warning message when user changes any value (text box/LOV) on page and close tab/cancel button by mistake.
Option I tried are:
a) Within application we are using a complex task flow/RegionModel for 7 different scenario's. Also requirement is to display custom message - Hence could not use approach "unsaveddatawarning"
http://www.oracle.com/technetwork/developer-tools/adf/unsaveddatawarning-100139.html
b) Second option I tried was to have custom region controller:
CustomRegionController implements RegionController
Inside validateRegion(RegionContext regionContext) thought to find if page data is dirty
AdfFacesContext.getCurrentInstance().getDirtyPageHandler().isDataDirty();
or
DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCDataControl cDataControl = dcBindings.getDataControl();
boolean dirtyFlag = cDataControl.isTransactionModified();
In both scenario it always gives true (seems due to common set of VO/View Link application module always gets dirty when data is being rendered on page load).
Last option I am left with is to invoke valueChangeListener for each element (textbaox, LOV, Check box). I do not like this option at all. Please suggest if there can be better way to handle this scenario.
Why is using a value change listener a problem? Have each input component call the same VCL method in the backing bean. If necessary you can get the component id from the vcl event object.

Resources