Sending parameter from web activity in Data Factory to logic apps - azure

I can successfully trigger Logic App from my Pipeline in ADFv2 via web activity. But now I would like to send also some user-defined parameters to logic app.
My question is now:
How can I send parameter from web Activity to logic app
How can I extract this parameter in logic app

On the Azure Data Factory-v2 side:
Click on the web activity. Go to the settings tab of the activity.
See this image for how to fill fields in settings tab
You have already figured what goes into URL and Method field in settings tab as you have successfully triggered logic app.
Let's suppose we want to send parameters in JSON (preferred way). Set 'NAME' Headers field to 'Content-Type' and 'VALUE' to 'application/json'.
In the body send you parameters in the form of JSON. Let's send following dummy parameters
{"Location":"northeurope","Model":"dummy_model","Server_name":"dummy_service","Onwer_email":"dummy#dummy.com"}
On the Logic App side:
You have already used 'When a HTTP request is received' trigger for logic app.
In the 'Request Body JSON Schema' field, enter the following schema to catch parameters send from ADFv2 web activity:
{
"properties": {
"Location": {
"type": "string"
},
"Model": {
"type": "string"
},
"Onwer_email": {
"type": "string"
},
"Server_name": {
"type": "string"
}
},
"type": "object"
}
See this image for help
You can also use 'Use sample payload to generate schema' instead of doing step 2 above. When using this option simply paste the json that you passed in body of ADFv2 web activity. It will automatically generate JSON schema to catch parameter.
Set the 'Method' field to the same method that you selected in ADFv2 web activity 'Method' field.
In subsequent steps in logic apps (for example initialize variable step) you can now use parameters set above (Location, Model, Onwer_email and Server_name) as Dynamic content using 'Add dynamic content' option. See this image for help.

Related

Create Sharepoint Site via REST API with multiple owners

So, I have a Power Automate Flow, which creates a Sharepoint Site using the Sharepoint REST API via "Send HTTP Request to Sharepoint" connector. I`ve following body:
{
"request": {
"Title": "#{variables('strSPName')}",
"Url":"#{variables('strSPAddress')}",
"Lcid": 1031,
"ShareByEmailEnabled":true,
"Description":"-",
"WebTemplate":"SITEPAGEPUBLISHING#0",
"SiteDesignId":"-",
"Owner": "#{outputs('Get_my_profile_(V2)')?['body/mail']}"
}
}
So right now I have only me as owner, but I need an additional owner.
I`ve tried to set two owners in an array like this:
"Owner": ["#{outputs('Get_my_profile_(V2)')?['body/mail']}", "email#test.com"]
Unfortunately, I`m getting the following error:
An unexpected 'StartArray' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected.
Any suggestions?
Thanks in advance.
As far as I am aware you can only set one owner when creating a site via the SPSiteManager endpoint. However, a workaround could be to add the second user to the Owners group directly after creation with a second POST request.
Below is an example
The principal id of the sitegroup should be 3.
Uri
_api/web/SiteGroups(3)/users
Body
{
"__metadata": { "type": "SP.User" },
"LoginName":"i:0#.f|membership|jane#contoso.onmicrosoft.com"
}

Why is the URI of an Azure runbook webhook URI blank

I am using an ARM template to deploy a logic app in a second subscription in Azure which needs to trigger a POST to a webhook URL of a runbook in the first subscription.
I use the full reference to the webhook URL object in the ARM template, but unforuntately although there is no error, the logic app ends up with a blank URI.
The reference to the webhook looks like:
"RunbookWebHook": {
"type": "string",
"defaultValue": "/subscriptions/----/resourceGroups/RunbookResources/providers/Microsoft.Automation/automationAccounts/RunbookAutomationAccount/webhooks/RunbookWebhook"
},
An example reference to the webhook URI in the logic app:
"actions": {
"Runbook_Webhook": {
"runAfter": {},
"type": "Http",
"inputs": {
"headers": {
"operationName": "#{triggerBody()['data']['operationName']}",
"resourceId": "#triggerBody()?['subject']"
},
"method": "POST",
"uri": "[reference(parameters('RunbookWebHook'), '2015-10-31').uri]"
}
}
How can I get the correct URL for the webhook URI?
This is because of a restriction in Azure with regards to the Webhook URL.
In the MicroSoft documentation: https://learn.microsoft.com/en-us/azure/automation/automation-webhooks#webhook-properties
it mentions the URL property (which is actually the uri field) and it says:
URL of the webhook. This is the unique address that a client calls with an HTTP POST to start the runbook linked to the webhook. It's automatically generated when you create the webhook. You can't specify a custom URL.
The URL contains a security token that allows a third-party system to invoke the runbook with no further authentication. For this reason, you should treat the URL like a password. For security reasons, you can only view the URL in the Azure portal when creating the webhook. Note the URL in a secure location for future use.
So the URL cannot be further retrieved after creation. :(

Dynamic Email attachment using Logic Apps via Data Factory

I need to build a generic Logic app using which i can send mail with attachment.
Is this possible to pass path and file name as parameter so i can use same logic app for different ADF pipelines.
Of course we can use a generic with a generic logic app. You just need to set the "When a HTTP request is received" trigger with two parameters, we can do it by specify the schema of it(shown like below).
schema:
{
"type": "object",
"properties": {
"path": {
"type": "string"
},
"fileName": {
"type": "string"
}
}
}
In following actions of your logic app, you can use the parameters path and fileName when you get the file from Azure Data Lake.
Then you can use the logic app in Azure Data Factory by a "Web" activity.

Creating Azure App Insights using REST API fails requires ROLE

I am generating API Key for an App Insight. I am using the URL
"https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys"
I don't have any clear documentation and I found this from the MS SDK:
https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/applicationinsights/Microsoft.Azure.Management.ApplicationInsights/src/Generated/APIKeysOperations.cs
However, when I try to generate by mentioning a "name", an error comes in response:
{
"code": "The API Key needs to have a Role",
"message": "The API Key needs to have a Role",
"innererror": {
"diagnosticcontext": "e1f66da1-9247-459e-a519-6426fa1449d1",
"time": "2019-09-20T07:48:20.2634617Z"
}
}
My POST body is as following:
{
"name": "asimplekeyname"
}
Please help if someone has used this specific API.
You need to include the following properties in the body.
{
"name":"test3",
"linkedReadProperties":[
"/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<appinsight-name>/api",
"/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<appinsight-name>/agentconfig"
],
"linkedWriteProperties":[
"/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<appinsight-name>/annotations"
]
}
The three properties correspond the ones in the portal -> your appinsight -> API Access -> Create API key.
api - Read telemetry
agentconfig - Authenticate SDK control channel
annotations - Write annotations
You need to select at least one of them, inculde in the request body.
For example, you just select the first one as below.
The body should be:
{
"name":"test3",
"linkedReadProperties":[
"/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<appinsight-name>/api"
],
"linkedWriteProperties":[]
}

How to attach file to email using REST API

I am working with emails from REST API.
I am able to create the email in the system and to update it.
The problem is with attaching files to the email to correct the images in the body of the email.
The endpoint for attaching files to records looks like below:
http://<Base endpoint URL>/<Top-level entity>/<Key value 1>/<Key value 2>/files/<File name>
The problem with emails is that the Key for emails is the NoteID field which can be accessed only using $custom parameter with requests like below:
https://baseurl/18.200.001/Email?$filter=From eq 'test#email.com'&$custom=Message.NoteID
This request will return a response like below
[
{
"id": "50bd83f1-b5bb-49f2-8ca9-6e55d6e10463",
"rowNumber": 1,
"note": "",
...
...
...
"custom": {
"Message": {
"NoteID": {
"type": "CustomGuidField",
"value": "9daca267-4bbd-e911-81ee-0259459e71e6"
}
}
},
"files": []
}
]
Where the NoteID corresponds to the one shown in the browser URL for the email
The problem is that when I try to send a request for attaching a file to that email using that NoteID or id from the response I always receive 'No entity satisfies the condition." error message in the request profiler.
Is there any other way to attach files using REST API?
After reviewing the OpenAPI 2.0 specification, comparing the specification for attaching files to different entities and checking keys of the entities it turned out that the Key of the entity must be specified in the Web Service Endpoint.
In the case of Email entity, the key field is NoteID and it is not specified in the endpoint, even more, it is not being shown in the lookup of the fields in the Web Service Endpoint.
But luckily, the system is allowing to manually write NoteID in the grid and save the endpoint like below:
and this entity is even passing the validation

Resources