问题
I can see in both the latest azure-mgmt-media & storage sdk's for Python the user is expected to pass in 2 args for Serializer/Deserializer. I've got very little Python experience and I can't figure out how to create these objects.
I can't find ANY media examples and no storage examples with the latest signature (3-01-18). I just want to create a media service asset and I don't know why I'd need to pass these args since I'm using standard SDK types. Can anyone point me to some examples of creating these? I can find
The documentation lists:
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
Two examples of these classes are: azure-sdk-for-python/azure-mgmt-media/azure/mgmt/media/operations/assets_operations.py
and
azure-sdk-for-python/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/blob_containers_operations.py
The signature is: def init(self, client, config, serializer, deserializer):
thanks!!!
Edited to append details of my issue trying to create a media asset:
import azure.mgmt.media as azuremedia
client = azuremedia.AzureMediaServices(credentials,
subscription_id)
assetOper = operations.AssetsOperations(client, client.config,
client._serialize, client._deserialize)
asset = assetOper.create_or_update(resource_group_name=resourceGroup,
account_name=accountName,
asset_name=assetName,
parameters=None)
^but the create_or_update method uses the code below and MY client's _serialize doesn't have a url property so it blows up!
From the top of the create_or_update method:
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'accountName': self._serialize.url("account_name", account_name, 'str'),
'assetName': self._serialize.url("asset_name", asset_name, 'str')
}
回答1:
Serializer and Deserializer are internal classes you're not supposed to create manually.
Instead, you must create a client that will do this for free for you. Please refer to this Storage Mgmt samples: https://github.com/Azure-Samples/storage-python-manage
The sample does not provide examples of "blob_containers", but will give you an overview on how to use "accounts" and the same logic will apply:
client.blobs_containers.get(rg_name, account_name, container_name)
You probably should do the short tutorial on SDK too: https://docs.microsoft.com/en-us/python/azure/python-sdk-azure-get-started?view=azure-python
There is no samples yet for media, but same logic applies.
(I own this code at MS)
来源:https://stackoverflow.com/questions/51217739/how-to-create-azure-mgmt-serializer-deserializer-parameters