Reputation: 3547
Based on the docs here: https://learn.microsoft.com/en-us/azure/media-services/latest/stream-files-tutorial-with-api
I've created a media services client and am attempting to create the new asset that will have the video file uploaded into it.
When I do this using the infromation provided on the API Access tab of the media service in question, the line: client.Assets.CreateOrUpdateAsync fails with "The resource type is invalid."
Anyone have any idea as to what is causing that and how to fix it? The sample is woefully out of date with credential management and the author is completely non-responsive for over a year.
Upvotes: 0
Views: 157
Reputation: 3547
So I found what this error actually means for anyone that hits this with the same problem:
It's the asset name. It has to conform to Windows file naming standards otherwise you'll get this unhelpful error.
Of course the error message should be updated to "invalid asset name, please ensure that it conforms to windows file naming conventions" but that's a separate bug report to Microsoft.
Upvotes: 1
Reputation: 2512
I just cloned the repo again myself, went to the portal and grabbed the JSON from the API Access blade and replaced the appsettings.json file (hit save), then hit F5 and it is running fine.
Can you try to clean that folder and re-clone the github project again.
git clone https://github.com/Azure-Samples/media-services-v3-dotnet-tutorials.git
Re-grab your credentials and replace them.
Make sure you open vscode from the "UploadEncodeAndStreamFile" folder as well. Seems to be working for me. Not sure why you would be seeing "resource type is invalid" actually. That sounds like something is named wrong in your appsettings.json file.
Also watch out for Asset Naming conventions, there are character limitations and lengths to be aware of - see here. https://learn.microsoft.com/en-us/azure/media-services/latest/media-services-apis-overview#naming-conventions
Naming conventions
Azure Media Services v3 resource names (for example, Assets, Jobs, Transforms) are subject to Azure Resource Manager naming constraints. In accordance with Azure Resource Manager, the resource names are always unique. Thus, you can use any unique identifier strings (for example, GUIDs) for your resource names.
Media Services resource names can't include: '<', '>', '%', '&', ':', '', '?', '/', '*', '+', '.', the single quote character, or any control characters. All other characters are allowed. The max length of a resource name is 260 characters.
Upvotes: 0