none
V2 SFTP Delete interfering with SFTP Trigger RRS feed

  • Question

  • In v1, we used an SFTP trigger which read and delete a file from an SFTP location. Now that both actions are separate and we try to delete the input file as soon as we archived it successfully (i.e. copy it to another separate location), the SFTP trigger stops working. Any suggestion?
    Thursday, March 10, 2016 9:09 PM

Answers

  • The Delete_File uses the file identifier (Id), instead of file name/relative path.

    In the Delete_File action, to delete a file created by Create_File action - use the Id output parameter (of Create_File) as value for File input parameter (of Delete_File). You can do this in the designer by simply selecting the Id parameter.

    Alternatively, you can make following change the code view for Delete_File:

    Old:

    "method": "delete",
    "path": "/datasets/default/files/@{encodeURIComponent(string('Archiving/BenefitFocus/iMax/test.txt'))}"

    New:

    "method": "delete",
    "path": "/datasets/default/files/@{encodeURIComponent(string(body('Create_file')['Id']))}"


    Monday, March 14, 2016 4:58 AM

All replies

  • Can you share your logic app definition? I will try to repro same scenario at my end.

    Also, do you have any failure messages around your trigger/workflow not working?

    Friday, March 11, 2016 8:06 AM
  • Hi! Thanks for the reply. I tried to repro this in an isolated logic app, just like you did, and I can't get the delete action to work. It always returns error 404 (not found). Here's the JSON:

    {  
    	"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2015-08-01-preview/workflowdefinition.json#",
    	  "actions": {    
    		"Create_file": {      
    			"conditions": [],
    			      "inputs": {        
    				"body": "@triggerBody()",
    				        "host": {          
    					"api": {            
    						"runtimeUrl": "https://logic-apis-eastus.azure-apim.net/apim/sftp"          
    					},
    					          "connection": {            
    						"name": "@parameters('$connections')['sftp']['connectionId']"          
    					}        
    				},
    				        "method": "post",
    				        "path": "/datasets/default/files",
    				        "queries": {          
    					"folderPath": "/Archiving/BenefitFocus/iMax",
    					          "name": "test.txt"        
    				}      
    			},
    			      "type": "ApiConnection"    
    		},
    		    "Delete_file": {      
    			"conditions": [        {          
    				"dependsOn": "Create_file"        
    			}      ],
    			      "inputs": {        
    				"host": {          
    					"api": {            
    						"runtimeUrl": "https://logic-apis-eastus.azure-apim.net/apim/sftp"          
    					},
    					          "connection": {            
    						"name": "@parameters('$connections')['sftp']['connectionId']"          
    					}        
    				},
    				        "method": "delete",
    				        "path": "/datasets/default/files/@{encodeURIComponent(string('Archiving/BenefitFocus/iMax/test.txt'))}"      
    			},
    			      "type": "ApiConnection"    
    		}  
    	},
    	  "contentVersion": "1.0.0.0",
    	  "outputs": {},
    	  "parameters": {    
    		"$connections": {      
    			"defaultValue": {},
    			      "type": "Object"    
    		}  
    	},
    	  "triggers": {    
    		"When_a_file_is_added_or_modified": {      
    			"conditions": [],
    			      "inputs": {        
    				"host": {          
    					"api": {            
    						"runtimeUrl": "https://logic-apis-eastus.azure-apim.net/apim/sftp"          
    					},
    					          "connection": {            
    						"name": "@parameters('$connections')['sftp']['connectionId']"          
    					}        
    				},
    				        "method": "get",
    				        "path": "/datasets/default/triggers/onupdatedfile",
    				        "queries": {          
    					"folderId": "/BenefitFocus/In/iMax"        
    				}      
    			},
    			      "recurrence": {        
    				"frequency": "Second",
    				        "interval": 15      
    			},
    			      "type": "ApiConnection"    
    		}  
    	}
    }
    I tried commenting the call to encodeUriComponent, but no matter what I do, it always returns error 404. Is there some issue with this API App?


    Friday, March 11, 2016 2:58 PM
  • The Delete_File uses the file identifier (Id), instead of file name/relative path.

    In the Delete_File action, to delete a file created by Create_File action - use the Id output parameter (of Create_File) as value for File input parameter (of Delete_File). You can do this in the designer by simply selecting the Id parameter.

    Alternatively, you can make following change the code view for Delete_File:

    Old:

    "method": "delete",
    "path": "/datasets/default/files/@{encodeURIComponent(string('Archiving/BenefitFocus/iMax/test.txt'))}"

    New:

    "method": "delete",
    "path": "/datasets/default/files/@{encodeURIComponent(string(body('Create_file')['Id']))}"


    Monday, March 14, 2016 4:58 AM
  • I'd like to add some information regarding this particular issue. The answer had to do with deleting the SFTP file, but the reason why my trigger was not being fired was because my logic app code had some errors which were not detected when saving inside code view. When I tried going to the designer, those errors were detected, and once I fixed them, the trigger began working fine again. You might want to check that the validations done when saving are the same ones as when going to the designer.
    Monday, March 14, 2016 3:01 PM