ADFv2: creating data source with a dynamic authenticated URL - azure

I have a pipeline that uses a Lookup activity with a POST REST service as the source dataset. This Lookup successfully retrieves a string from the body that is then passed as an "access token" inside the header of GET Web activity.
This GET Web activity then returns a set of 3 values inside the body of the return: fileURL, sasToken, fileaccessURL. The "fileaccessURL" is simply a concatenation of "fileURL" and "sasToken"
The new dynamically created "fileaccessurl" points to a ZIP file inside a blob storage housed with my partner company. This ZIP file contains that actual data I want to use as my data source. I am OK with deflating the file once I get it and using the files within as my actual source.
The issue I'm having is how to specify that the dynamically assigned "fileaccessurl" is my data source for getting that initial ZIP file? I can't parameterize REST or HTTP linked services or figure out any other way to set this. I have already eliminated the option of connecting directly to the partner blob storage. I have tried using lookups but I still can't figure out how to specify my destination with a URL that isn't necessarily always the same.

If you are looking for how to parameterize linked service, you can try to use the advanced part and check "specify dynamic content in JSON format".
This is the sample JSON code:
{
"name": "AzureSqlDatabase",
"properties": {
"type": "AzureSqlDatabase",
"typeProperties": {
"connectionString": {
"value": "Server=tcp:myserver.database.windows.net,1433;Database=#{linkedService().DBName};User ID=user;Password=fake;Trusted_Connection=False;Encrypt=True;Connection Timeout=30",
"type": "SecureString"
}
},
"connectVia": null,
"parameters": {
"DBName": {
"type": "String"
}
}
}
}
You can try to modify the code to align with Rest or HTTP linked service payload.

Related

Microsoft Graph create share link for specific people

I would like to share document by link in sharepoint from microsoft graph code. Default behaviour is that every person who has link can see this file. I want to make this link working just for specific people.
So my code look like this:
Permission permission = await _graphClient.Sites[_options.SiteId]
.Drives[driveId]
.Items[itemId]
.CreateLink("view", "organization")
.Request()
.PostAsync();
This create share link for all people in organization. Now I would like to grant permissions (https://learn.microsoft.com/en-us/graph/api/permission-grant?view=graph-rest-1.0&tabs=csharp)
await graphClient.Shares["{sharedDriveItem-id}"].Permission
.Grant(roles,recipients)
.Request()
.PostAsync();
But I have no idea what should be in place "{sharedDriveItem-id}". When I put there itemId it doesn't work. Also if I put there permission.link.webUrl it also doesn't work.
What am I doing wrong?
From this documentation.
Once you create the shared link the response object returns an id, that's what you should use in place of the {sharedDriveItem-id}. See a similar response object below.
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "123ABC", // this is the sharedDriveItem-id
"roles": ["write"],
"link": {
"type": "view",
"scope": "anonymous",
"webUrl": "https://1drv.ms/A6913278E564460AA616C71B28AD6EB6",
"application": {
"id": "1234",
"displayName": "Sample Application"
},
},
"hasPassword": true
}
Okey, I found solution. There are few steps:
As sharedDriveItem-id I used encoded webUrl following by this instruction https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http
When I was creating link (https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http) in place scope i put "users"- there is no option like that in documentation but without that it doesn't work
I added Prefer in header https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http
I was using clientSecret/clientId authorization so I had to add azure app access to Sites.Manage.All and Sites.FullControl.All in Graph Api Permissions
Everything works If you using Microsoftg.Graph nuget in newest version (4.3 right now if I remember correctly)

Azure Search, listAdminKeys, ARM output error (does not support http method 'POST')

I am using this bit of code as an output object in my ARM template,
"[listAdminKeys(variables('searchServiceId'), '2015-08-19').PrimaryKey]"
Full text sample of the output section:
"outputs": {
"SearchServiceAdminKey": {
"type": "string",
"value": "[listAdminKeys(variables('searchServiceId'), '2015-08-19').PrimaryKey]"
},
"SearchServiceQueryKey": {
"type": "string",
"value": "[listQueryKeys(variables('searchServiceId'), '2015-08-19')[0]]"
}
I receive the following error during deployment (unfortunately, any error means the template deployment skips output section):
"The requested resource does not support http method 'POST'."
Checking the browser behavior seems to validate the error is related to the function (and, it using POST).
listAdminKeys using POST
How might I avoid this error and retrieve the AzureSearch admin key in the output?
Update: the goal of doing this is to gather all the relevant bits of information to plug into other scripts (.ps1) as parameters, since those resources are provisioned by this template. Would save someone from digging through the portal to copy/paste.
Thank you
You error comes from listQueryKeys, not admin keys.
https://learn.microsoft.com/en-us/rest/api/searchmanagement/adminkeys/get
https://learn.microsoft.com/en-us/rest/api/searchmanagement/querykeys/listbysearchservice
you wont be able to retrive those in the arm template, it can only "emulate" POST calls, not GET
With the latest API version, it's possible to get the query key using this:
"SearchServiceQueryKey": {
"type": "string",
"value": "[listQueryKeys(variables('searchServiceId'), '2020-06-30').value[0].key]"
}

Acumatica run report from REST API

I need to get accurate inventory numbers via the Acumatica API so that I can update inventory on an external site. Our only method of getting accurate inventory is running a report under Distribution -> Inventory -> Reports Tab then selecting Inventory Balance and running the report without an Inventory ID so I get a full list of all inventory in our system. How can I run this report (or any report) via Acumatica's API? I can use REST or SOAP in this case.
I need the data from the report in a manner that I can consume it in my C# application and use it to update a database on an external site. So for example, if I were using the REST API, I would want a report returned in JSON format. Example desired return below:
{
"InventoryID": {
"value": "CW-500-MC-30"
},
"Warehouse": {
"value": "WH1"
},
"Description": {
"value": "Milk chocolate chews"
},
"Available": {
"value": 8
}
},
{
"InventoryID": {
"value": "AB-100-SE-30"
},
"Warehouse": {
"value": "WH1"
},
"Description": {
"value": "Face lotion"
},
"Available": {
"value": 12
}
}
As mentioned in the Appendix of the I210 course pdf section Generate a printable invoice by invoice ID :
This web integration scenario is not supported in the available versions of system endpoints. If you need to generate reports, you can use the screen-based SOAP API. For details, see the I200 Screen-Based Web Services training course in Acumatica University.
Looking in that course and following the Example 4.3.3: Generating the Printable Version of an Invoice will show how to get a report through the API.
Which can be resumed by putting the following information in the command list sent through the API.
The different parameters that need to be set for the report
A mention to the PDF Content from the Report Result so that the API knows that must return it to you.
After that you only need to use any library capable of writing to your file system in order to create the PDF file with the information you just received.

Which action(s) can I use to create a folder in SharePoint Online via Azure Logic App?

As question title states, I am looking for a proper action in Logic Apps to create a folder. This action will be executed several times -- once per directory as per business rule. There will be no files created in these folders because the intent of the Logic App is to prepare a template folder structure for the users' needs.
In the official documentation I see that there are create file, create item, and list folder actions. They suggest that there might be an action to create a folder too (which I can't find).
If such action does not exist, I may need to use some SharePoint Online API, but that will be a last resort solution.
I was able to create a directory by means of SharePoint - CreateFile action. Creating a directory via a side effect of the file creation action is definitely a dirty hack (btw, inspired by a comment on MS suggestion site). This bug/feature is not documented, so relying on it in production environment is probably not a good idea.
More that that, if my problem requires creating a directory in SharePoint without any files in it whatsoever, an extra step in App Logic needs to be used. Make sure to delete the file using the Id provided by Create File action.
Here's what your JSON might look like, if you were trying to create a directory called folderCreatedAsSideEffect under preexisting TestTarget document library.
"actions": {
"Create_file": {
"inputs": {
"body": "#triggerBody()?['Name']",
"host": { "connection": { "name": "#parameters('$connections')['sharepointonline']['connectionId']" } },
"method": "post",
"path": "/datasets/#{encodeURIComponent(encodeURIComponent('https://MY.sharepoint.com/LogicApps/'))}/files",
"queries": {
"folderPath": "/TestTarget/folderCreatedAsSideEffect",
"name": "placeholder"
}
},
"runAfter": {},
"type": "ApiConnection"
},
"Delete_file": {
"inputs": {
"host": { "connection": { "name": "#parameters('$connections')['sharepointonline']['connectionId']" } },
"method": "delete",
"path": "/datasets/#{encodeURIComponent(encodeURIComponent('https://MY.sharepoint/LogicApps/'))}/files/#{encodeURIComponent(body('Create_file')?['Id'])}"
},
"runAfter": {
"Create_file": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
Correct, so far the SharePoint Connector does not support Folder management tasks.
So, your best option currently is to use the SharePoint API or client libraries in an API or Function App.

Pass the output of SQL Connector to Custom Api App

I have a logic app which is triggered manually. The first connector is SQL connector which executes a stored proc and retrieves the data (json array). Now I want to pass this as an input to my custom api app. Below is the snap shot of my custom api method signature
After I add my custom api app I get the below screen. How do I pass the output of my SQL connector as an input to my API app?
Additionally I am confused as to why is the UI displaying me individual properties of my Customer class. Isn't it supposed to give me one big box to provide the json array input? I also tried entering static values in the input fields but then the option to save the logic app gets grayed out. I tried assigning the value #body('Execute_stored_procedure')['ResultSets']['Table1'] to the body property of the api app in the code view and even after saving it successfully the value is reset to null when I load the designer again.
Below is the sample response from the SQL connector stored proc
{
"body": {
"OutputParameters": {},
"ReturnCode": 0,
"ResultSets": {
"Table1": [
{
"FirstName": "Karen",
"LastName": "Choi",
"EmailAddress": null,
"PhoneNumber": null,
"PostalCode": "98104",
"City": "Seattle",
"Address": "Hidden",
"StateCode": "Washington"
},
{
"FirstName": "Jeanne",
"LastName": "Blake",
"EmailAddress": null,
"PhoneNumber": null,
"PostalCode": "90012",
"City": "Los Angeles",
"Address": "Hidden",
"StateCode": "California"
}
]
}
PS: I am using the new version of the logic apps. My custom API app used to work perfectly with the old version of the logic app.
EDIT
The logic app prevents me to save if I enter the static values on the UI. In the below image the Save option is disabled
EDIT 2
I found a strange behaviour. If I add a condition to the output of SQL connector I can see all the output properties of the SQL Connector.
Why is it that I can't see the same set of properties when I add my custom connector (Figure 2)?
Could you try to use #body('ResultSets').Table1 instead in the code view ?
Have you tried
#body('theSQLConnectorName').OutputParameters.result (alt. .ResultSet)
?

Resources