How to prevent Truncated URL on JobInput with python sdk

Benjamin Dean 1 Reputation point
2020-11-18T19:31:22.357+00:00

When submitting a job to Azure Media Services, I'm getting an error because the input url is being truncated unexpectedly.

   #python 2  
   from msrestazure.azure_active_directory import ServicePrincipalCredentials  
   from azure.mgmt.media import AzureMediaServices, models  
     
   from django.conf import settings  
   from datetime import datetime  
     
   tenant_id = settings.AZURE_TENANT_ID  
   subscription_id = settings.AZURE_SUBSCRIPTION  
   client_id = settings.AZURE_CLIENT_ID  
   client_secret = settings.AZURE_CLIENT_SECRET  
   resource_group_name = settings.AZURE_RESOURCE_GROUP  
   account_name = settings.AZURE_MEDIA_SERVICE_ACCOUNT_NAME  
   credentials = ServicePrincipalCredentials(client_id, client_secret, tenant=tenant_id)  
     
   ams = AzureMediaServices(credentials, subscription_id)  
   preset = models.BuiltInStandardEncoderPreset(preset_name='H264MultipleBitrateSD')  
   transform_output = models.TransformOutput(preset=preset)  
   outputs = [transform_output]  
   transform_name = "Alfa"  
   transform =  ams.transforms.create_or_update(  
      account_name=account_name, outputs=outputs, resource_group_name=resource_group_name, transform_name=transform_name  
   )  
   #### everything up to here is working as expected, but included for completeness ####  
     
   input_url = ("https://download-whatever.somewhere-dev.com/api/download/v1/blob?t=blahblah"  
       "qaf8&c=qaf8&id=bf04fd7a-167a-4fa7-9e29-ed88525dd03b&et=20201117212714&isfullc"  
       "ontainername=True&sig=nMEXM90SKC3imXnYrgb2bA9oMMSe6nh1mD6nrEnA4cE%3D"  
       )  
   input = models.JobInputHttp(files=[input_url])  
   # input.files shows correct list with single correct url at this point  
   asset_name = "out-{}".format(datetime.utcnow().isoformat())  
   asset = ams.assets.create_or_update(resource_group_name, account_name, asset_name, {})  
   output = models.JobOutputAsset(asset_name=asset.name)  
   local_job = models.Job(input=input, outputs=[output])  
   # local_job.input.files shows the list of single correct url, too  
   job_name = "job-{}".format(datetime.utcnow().isoformat())  
   created_job = ams.jobs.create(resource_group_name, account_name, transform.name, job_name, local_job)  
   # created_job.input.files  
   #  [u'https://download-whatever.somewhere-dev.com/api/download/v1/blob']  
   # here's the problem--why is ^ truncated at the query params?  

The docs say that if only files is specified, no transformation is to take place

If no base uri is given, then the provided file list is assumed to be fully qualified uris.

Creating the input with base_uri=u'https://download-whatever.somewhere-dev.com/api/download/v1/blob' and files=?t=blahblahqaf8&c=qaf8&id=bf04fd7a-167a-4fa7-9e29-ed88525dd03b&et=20201117212714&isfullcontainername=True&sig=nMEXM90SKC3imXnYrgb2bA9oMMSe6nh1mD6nrEnA4cE%3D" yields the same result.

So how does that URL get truncated? What can I do to prevent it?

Azure Media Services
Azure Media Services
A group of Azure services that includes encoding, format conversion, on-demand streaming, content protection, and live streaming services.
316 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,106 Reputation points Microsoft Employee
    2020-11-23T17:54:22.497+00:00

    Hi @Benjamin Dean ,

    I've confirmed with our engineers that this is intended behavior and doesn't indicate a problem. In fact, you would see the same response if you were submit the request using the REST API...

    PUT https://management.azure.com/subscriptions/<subscriptionID>/resourceGroups/<resourceGroup>/providers/Microsoft.Media/mediaServices/<accountName>/transforms/<transformName>/jobs/<jobName>?api-version=2018-07-01 HTTP/1.1  
    accept-language: en-US  
    Authorization: Bearer <redacted>  
    Content-Type: application/json; charset=utf-8  
    Host: management.azure.com  
    Expect: 100-continue  
      
    {  
      "properties": {  
        "input": {  
          "@odata.type": "#Microsoft.Media.JobInputHttp",  
          "files": [  
            "https://account.blob.core.windows.net/container/Dolphins_720.wmv?sv=2019-10-10&st=2020-11-23T16%3A41%3A11Z&se=2030-11-24T16%3A41%3A00Z&sr=b&sp=r&sig=%2FZ4M4VGEyAWN0Cxh7bJ4FIjOdw0Rq%2FBsmcoB3I8x7Fk%3D"  
          ]  
        },  
        "outputs": [  
          {  
            "@odata.type": "#Microsoft.Media.JobOutputAsset",  
            "assetName": "httpsource-StandardEncoder-AdaptiveStreaming-22c715fc5d"  
          }  
        ]  
      }  
    }  
    

    ...you would get the trimmed URL in the response:

    HTTP/1.1 201 Created  
    Cache-Control: no-cache  
    Pragma: no-cache  
    Content-Length: 939  
    Content-Type: application/json; odata.metadata=minimal  
    Expires: -1  
    OData-Version: 4.0  
    Server: Microsoft-HTTPAPI/2.0  
    x-ms-ratelimit-remaining-subscription-resource-requests: 11999  
    Strict-Transport-Security: max-age=31536000; includeSubDomains  
    X-Content-Type-Options: nosniff  
    Date: Mon, 23 Nov 2020 16:56:50 GMT  
      
      
    {​​​​​​​  
      "name":"<jobName>","id":"/subscriptions/<subscriptionI>/resourceGroups/<resourceGroup>/providers/Microsoft.Media/mediaservices/<accountName>/transforms/<transformName>/jobs/job-<jobName>","type":"Microsoft.Media/mediaservices/transforms/jobs","properties":{​​​​​​​  
        "created":"2020-11-23T16:56:50.6987444Z","state":"Scheduled","input":{​​​​​​​  
          "@odata.type":"#Microsoft.Media.JobInputHttp","files":[  
            "https://account.blob.core.windows.net/container/Dolphins_720.wmv"  
          ]  
        }​​​​​​​,"lastModified":"2020-11-23T16:56:50.6987444Z","outputs":[  
          {​​​​​​​  
            "@odata.type":"#Microsoft.Media.JobOutputAsset","state":"Queued","progress":0,"label":"BuiltInStandardEncoderPreset_0","assetName":"<assetName>"  
          }​​​​​​​  
        ],"priority":"Normal","correlationData":{​​​​​​​  
            
        }​​​​​​​  
      }​​​​​​​  
    }​​​​​​​  
    

    Regards,
    Ryan

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.