Are you having issues with az apim create?

Here it is a small work around for the current bug when adding managed identity.

az apim create --name $name `
               --publisher-email $publisher.email `
               --publisher-name $publisher.name `
               -g $resourceGroup #--enable-managed-identity true
az apim update --name $name -g $resourceGroup --enabled-managed-identity true