1

I'm trying to create a public ip address in Azure with the Python SDK and I can't figure out why am I getting an error. Here's my code :

netclient.public_ip_addresses.create_or_update('testgrp','testsdknic',{'location':'uksouth','sku':'standard','public_ip_allocation_method':'dynamic','public_ip_address_version':'ipv4'})

And this is the error I get :

SerializationError: Unable to build a model: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get', DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'

I have tried several things but while I'm succeeding in creating a network interface, I can't create the public IP. Could anyone provide me with some guidance here please ? Many thanks in advance.

1 Answer 1

1

For this issue, it caused by the property sku of the public IP address, it's the string, but a PublicIPAddressSku. So the code you need to change into this:

netclient.public_ip_addresses.create_or_update('testgrp','testsdknic',{'location':'uksouth',
'sku':{'name': 'standard'},'public_ip_allocation_method':'static','public_ip_address_version':'ipv4'})

And watch out, when you use the standard for the public IP address, then it should be in the static allocation method.

Sign up to request clarification or add additional context in comments.

1 Comment

You've nailed it ! thanks. I must confess that I have a real hard time understanding Microsoft doc. The AWS Boto3 one is so much clearer ! Anyway thanks for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.