none
azure logic app RRS feed

  • Question


  • Hello
     i generate logic app for generate sprite thumbnail on first generate job and its work fine then i add cheak job state function inside until and add this coundition"@body('cheakJobState')['d']['results'][0]['State']" is not equal 3 and i give cheakJobState this condition "@body('cheakJobState')['d']['results'][0]['State']" but its give me error



    • Edited by afaq smadi Wednesday, August 7, 2019 2:07 PM
    Wednesday, August 7, 2019 12:21 PM

All replies

  • i need to ask how can return body for function on azure function app
    Thursday, August 8, 2019 8:04 AM
  • We would like to work closer with you on this matter. Can you please reach out to us at azcommunity@microsoft.com with your subscription ID and the URL of this post? We look forward to your reply.
    Thursday, August 8, 2019 9:47 AM
    Moderator
  • Hello

    This is the function and the status code  is 200 and its create job but it dosen't  print any things on logs my question how can this function return jobId to use it on another function 

    const https = require('https')
    const http = require('http');
    var bodyParser = require('body-parser');
    var request = require('request');
    const axios = require('axios');
    var Promise = require('promise');
    const adal = require('adal-node').AuthenticationContext;
    module.exports =sync function(context, req,res) {
    const authorityHostUrl = 'https://login.windows.net';
    const tenant = '*****';
    const authorityUrl = authorityHostUrl + '/' + tenant;
    const clientId = '******';
    const clientSecret = '******';
    const resource = 'https://rest.media.azure.net';
    const context1 = new adal(authorityUrl);
    context1.acquireTokenWithClientCredentials(
    resource,
    clientId,
    clientSecret,
    (err, tokenResponse) => {
    if (err) {
    context.log(`Token generation failed due to ${err}`);
    } else {
    global.souresAssetId=req.body.assetId
    global.souresAsset=req.body.assetId.substr(12)
    var accessToken=tokenResponse.accessToken
    var config={
    "Version": 1.0,
    "Codecs": [
    {
    "Start": "00:00:00",
    "Type": "JpgImage",
    "Step": "00:00:10",
    "Range": "25%",
    "JpgLayers": [
    {
    "Type": "JpgLayer",
    "Width": "10%",
    "Height": "10%",
    "Quality": 50,
    "Label": "web1"
    },
    {
    "Type": "JpgLayer",
    "Width": "318",
    "Height": "180",
    "Quality": 50,
    "Label": "tv1"
    },
    {
    "Type": "JpgLayer",
    "Width": "107",
    "Height": "60",
    "Quality": 50,
    "Label": "mobile1"
    },
    {
    "Type": "JpgLayer",
    "Width": "190",
    "Height": "126",
    "Quality": 50,
    "Label": "tab1"
    }
    ],
    "SpriteColumn": 10
    },
    {
    "Start": "25%",
    "Type": "JpgImage",
    "Step": "00:00:10",
    "Range": "50%",
    "JpgLayers": [
    {
    "Type": "JpgLayer",
    "Width": "10%",
    "Height": "10%",
    "Quality": 50,
    "Label": "web2"
    },
    {
    "Type": "JpgLayer",
    "Width": "318",
    "Height": "180",
    "Quality": 50,
    "Label": "tv2"
    },
    {
    "Type": "JpgLayer",
    "Width": "107",
    "Height": "60",
    "Quality": 50,
    "Label": "mobile2"
    },
    {
    "Type": "JpgLayer",
    "Width": "190",
    "Height": "126",
    "Quality": 50,
    "Label": "tab2"
    }
    ],
    "SpriteColumn": 10
    },
    {
    "Start": "50%",
    "Type": "JpgImage",
    "Step": "00:00:10",
    "Range": "75%",
    "JpgLayers": [
    {
    "Type": "JpgLayer",
    "Width": "10%",
    "Height": "10%",
    "Quality": 50,
    "Label": "web3"
    },
    {
    "Type": "JpgLayer",
    "Width": "318",
    "Height": "180",
    "Quality": 50,
    "Label": "tv3"
    },
    {
    "Type": "JpgLayer",
    "Width": "107",
    "Height": "60",
    "Quality": 50,
    "Label": "mobile3"
    },
    {
    "Type": "JpgLayer",
    "Width": "190",
    "Height": "126",
    "Quality": 50,
    "Label": "tab3"
    }
    ],
    "SpriteColumn": 10
    },
    {
    "Start": "75%",
    "Type": "JpgImage",
    "Step": "00:00:10",
    "Range": "100%",
    "JpgLayers": [
    {
    "Type": "JpgLayer",
    "Width": "10%",
    "Height": "10%",
    "Quality": 50,
    "Label": "web4"
    },
    {
    "Type": "JpgLayer",
    "Width": "318",
    "Height": "180",
    "Quality": 50,
    "Label": "tv4"
    },
    {
    "Type": "JpgLayer",
    "Width": "107",
    "Height": "60",
    "Quality": 50,
    "Label": "mobile4"
    },
    {
    "Type": "JpgLayer",
    "Width": "190",
    "Height": "126",
    "Quality": 50,
    "Label": "tab4"
    }
    ],
    "SpriteColumn": 10
    }
    ],
    "Outputs": [
    {
    "FileName": "{Basename}_{Index}_{Label}{Extension}",
    "Format": {
    "Type": "JpgFormat"
    }
    }
    ]
    }
    const data ={
    "Name":"Quality equal 50"+souresAssetId,
    "InputMediaAssets" : [{"__metadata": {"uri" : "https://shahiddotnet.restv2.westeurope.media.azure.net/api/Assets('"+souresAssetId+"')"}}],
    "Tasks": [{
    "Configuration":JSON.stringify(config),
    "MediaProcessorId":"nb:mpid:UUID:ff4df607-d419-42f0-bc17-a481b1331e56",
    "TaskBody":"<?xml version=\"1.0\" encoding=\"utf-8\"?><taskBody><inputAsset>JobInputAsset(0)</inputAsset><outputAsset assetName=\"Sprite Thumbnail\">JobOutputAsset(0)</outputAsset></taskBody>"
    }]
    }
    var header2={
    'Accept': 'application/json;odata=verbose',
    'Authorization':'Bearer '+accessToken,
    'Content-Type': 'application/json;odata=verbose',
    'DataServiceVersion': '3.0',
    'MaxDataServiceVersion': '3.0',
    'x-ms-version': '2.15'
    }
    var url3="https://*****.restv2.westeurope.media.azure.net/api/Jobs"
    request(
    {
    headers: header2 ,
    uri:url3,
    method:'POST',
    body: data,
    json: true
    }, function (err, res, body) {
    globle.idJob=body.d.Id
    //context.res(body)
    })
    }
    }
    );
    // })();
    }

     
    Wednesday, August 14, 2019 12:11 PM