Googleアナリティクス

2017年8月15日火曜日

Determine new service of LogicApps using Table Storage

Original Post is here.

Currently on my Twitter account, I've continued to count "tweet the number of services" that I built earlier. This is fine, but as it has become increasingly difficult to check what happened when the corresponding service actually increased, I also tried that point.

First of all, I will create an Azure Table Storage that will be the data storage destination, but now there are two types, Table Storage or Table Storage of Cosmos DB. Although Cosmos DB is more resistant to obstacles and is suitable for practical operation, on the other hand, since the conventional table storage has advantages in terms of cost, it is necessary to use properly. However, since LogicFlow will have similar operations and settings in both cases, you do not need to be conscious of that much.

image

In preparation for the preparation, it is necessary to introduce the current service information in Table Storage in advance.

image

In the conventional table storage, a new storage account is created and the flow to create subordinate services such as Blob and Table under it. If you click "Table" on the above screen, it will change to the list screen which can create table storage.

image

Click "Table" in the top menu of this orchid screen to create a new table.

image

Creating a table does not have any difficult things, just setting the table name. You are now ready to use Table Storage.

image

To use Table Storage from LogicFlow, you need an account name and access key, so open the "Access Key" blade and keep a note of the information.

In the preparation for this time, LogicFlow prepares usual access token is acquired. Based on that information, we got the actual service information and updated the result to table storage.

image

The point that becomes the point is this part after obtaining the service information. The acquired service information is changed to an array of only names and details by "select" action, and the array is used for updating to the table storage.

This is not because we are trying to limit the information, but because there is a table storage specification "can hold only flattened information". In other words, in JSON and others, values with multiple properties, such as prop.name, prop.description, prop.api ... etc., can not be updated with such values intact and result in an error.

image

For this reason, we narrowed down the value only to the service name and details this time and flatten it. Azure Storage Explorer is useful for checking actually updated data.

image

You can check the inside of the actual storage, so you can check if the update is done well.

By making preparations under this condition, we can compare it with the latest service information we have acquired and make it possible to judge newly added service.

image

To make a judgment in that case it will be LogicFlow like above. Loop on the acquired latest service information with ForEach and acquire it from Table Storage on the basis of the acquired name (note that there are two name properties on JSON).

Whether the acquired result exists or not is determined using the length function. The result of the length function is 0 = there is no data in the table storage = new service. Judgment is possible.

On the contrary, even if it is not included in the latest information but it is included in the table storage, it is also possible to deal with it. In this case, the ForEach loop is performed with the data of the Table Storage (In the past, there was a missing service because it was released by mistake etc. ...)

When acquiring data from Table Storage, you need to get used to it a bit.

image

In the FIltter Query item in the detailed option, it is possible to specify conditions for acquisition, but as mentioned above, we use our own syntax (close to the HTTP query parameter). About this description official document There is, so please refer to it.

Select Query is where you specify the items to be retrieved as a result.

Combining LogicFlow in this way makes it possible to do various things almost even in a cordless state. Depending on the idea, the place where I thought that the code was necessary would be able to correspond with the cordless, which would allow more room to undertake more important points.

0 件のコメント:

コメントを投稿