Operation returned an invalid status code 'NotFound' DotNet Core

2.8k views Asked by At

I am working on DOT 5.0 Version. (CORE MVC Application).

While uploading my file in Azure (During Encoding) Facing an Error.

Asset outputAsset = await CreateOutputAssetAsync(client, config.ResourceGroup, config.AccountName,
                                            outputAssetName, uploadedAsset.Description);
private static async Task<Asset> CreateOutputAssetAsync(IAzureMediaServicesClient client,
            string resourceGroupName, string accountName, string assetName, string assetDescription)
        {
            // Check if an Asset already exists
            Asset outputAsset = await client.Assets.GetAsync(resourceGroupName, accountName, assetName);
string outputAssetName = assetName;
Asset asset = new Asset()
            {
                Description = "Encoded-" + assetDescription,
                StorageAccountName = "MyStoarestorage" 
           };
           return await client.Assets.CreateOrUpdateAsync(resourceGroupName, accountName, outputAssetName, asset);
        }

The line await the client.Assets.GetAsync failed. Did I have missed any packages? Follow the below URL and Install it. (https://learn.microsoft.com/en-us/azure/media-services/latest/configure-connect-dotnet-howto).

Please Suggest. Note:- SAME CODE IS WORKING FINE IN MY DESKTOP APPLICATION And UPLOAD VIDEO WITH ENCODING IN AZURE. but When to apply the SAME CODE .NET 5.0 CORE MVC Application some how it is not working

1

There are 1 answers

0
Girish On BEST ANSWER

In Microsoft.Azure.Manangement.Media version 5.0, we have a breaking change for get functions trying to retrieve non-existing assets (source):

  • All calls returning 404 Not found raises an ErrorResponseException instead of returning null. This change was make to be consistent with other Azure SDKs.

Can you check if you are using an older version of the library in your desktop application? That might be the reason for the difference in behavior.