Googleアナリティクス

2018年6月15日金曜日

Template Logic Apps including API connection

ORiginal Post is here.

Although I was doing various templates to distribute Logic Apps including API connection, I tried collecting it as a memorandum because I took a lot of trouble in rewriting the point and Template when distributing it.

This entry was made with reference to Sacha Bruttin 's wonderful entry. Deploy Logic Apps & API Connection with ARM https://www.bruttin.com/2017/06/13/deploy-logic-app-with-arm.html

First, some sort of LogicFlow will be output as a template.

image

The template output itself can be implemented by selecting the Automation script from the menu when Logic Apps is opened. However, contents outputted at that time are output as they are, such as the subscription ID and API connection information, and can not be used if you want to distribute it to another environment or another subscription.

In such a case, we will use the parameters prepared in ARM Template.

image

Parameter definitions are described in the parameters section of Template. Required is the type element.stringsecureStringintboolobjectsecureObjectarray secureString is an input format used for passwords etc. It is masked and displayed. Various specifications such as definition of choice are available in addition. Refer to the official document .

image

Since I wanted to use the CognitiveService API this time, I made it possible to specify "API key" and "site URL" with parameters as described above. Parameters prepared here will be prompted for input when deployed to Azure.

image

Based on the information entered here, I will make it a template to create a new API connection this time. Where I checked this API key and site URL is based on information that can be obtained from the connector side of LogicApps.

Previous entry get service information on Logic Apps . As information that can be obtained at that time, items necessary for use are also included.

image

The above is information on the ComputeVision API connector. It contains information on the information required for the connectionParameters element. As you can see here, apiKey and siteUrl are necessary here. I am trying to input this as a parameter.

This is set the API connection using the parameters defined below.

image

This is the API connection part in the template outputted by the Automation script. It is written that the resource ID is outputted and API connection information is used, With the description of the number, it is in a shape that can not be newly created. It is necessary to rewrite it to a form that can register newly using the parameter here.

image

Rewritten result is like this。

The name element is the name in the API connection setting. Since we want to use the parameters here "name": "[parameters ('connections_name')]" . Surrounded by [] is a specification to use the result as a character string.

The location element is a region for using the API. In this time I will write "location": "[resourceGroup (). Location]" so that the Region of Logic Apps and API are identical. Writing "resourcGroup" is a function available in the ARM template, and you can obtain the selected region at the time of deployment.

In the propeties element, specify unique information. In this case, API key and site URL information are described here. In the example above, we list the parameterValues element in the properties element, and the necessary information in it. In this case it is necessary to describe in the form of key name: value, the key name must match the name contained in the connector information. Parameter names and so on are fine even if you define the name freely.

Another important part is the ID value of the api element. In this example, we define values to be used inside the template, but they are described as fixed with the subscription ID and location unchanged. Therefore, rewrite it so that it becomes variable by using resourceGroup function etc.

"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', parameters('connections_name'))]"

In this way, make the subscription ID and location variable.

Where the value specified here relates, it is around the connection information inside LogicFlow definition.

image

It is very difficult to understand the relevance of this area, and I do not yet understand it well, but it seems to me that it is based on the following rules.

  • $ connection specifies information to be searched when referring to the connection from LogicFlow
  • Apparently the element name under connectionName or value here is fixed?
  • connectionID is connection information ("Type": information defined in "Microsoft.Web / connections")
  • The ID is different from the ID described in the connection information. If it is not a URL accessed by Logic Apps, an error occurs at the time of deployment

Trying to apply the parameters here was the most troublesome ... I still can not understand it well. However, by doing so, it became a template that can variably use subscription ID, location, API connection information, etc., making distribution easier.

image

Where you use the API, the connection name is specified as described above, and $ connection is searched here for the connection name. In this case, it is written to refer to the new API connection. If you rewrite a little bit here, you will not be able to find it in practice because it has become a deployment error in general.

Since I understand somehow as a way to enter parameters in some form at the time of expansion, it can be distributed so that it is easy to use a little.

0 件のコメント:

コメントを投稿