user1166286
user1166286

Reputation: 11

Unable to find Rest api reference for deleting azure vm endpoint

I am trying to find the rest api reference for deleting the azure vm endpoint configured. i got the rest api reference for update/create endpoints over the below link but unable to get the reference for deleting the enpoint. do any one have tried to delete the endpoint using rest api. if so kindly share how to delete the endpoint of a vm in azure using rest api.

http://msdn.microsoft.com/en-us/library/jj157187.aspx - Update Role

Thanks in Advance.

Upvotes: 0

Views: 180

Answers (2)

Thomas Decaux
Thomas Decaux

Reputation: 22661

You can have a look on the Azure Ruby SDK:

https://github.com/Azure/azure-sdk-for-ruby/blob/master/lib/azure/virtual_machine_management/virtual_machine_management_service.rb#L413

def delete_endpoint(vm_name, cloud_service_name, endpoint_name)
        vm = get_virtual_machine(vm_name, cloud_service_name)
        if vm
          path = "/services/hostedservices/#{vm.cloud_service_name}/deployments/#{vm.deployment_name}/roles/#{vm_name}"
          endpoints = vm.tcp_endpoints + vm.udp_endpoints
          endpoints.delete_if { |ep| endpoint_name.downcase == ep[:name].downcase }
          body = Serialization.update_role_to_xml(endpoints, vm)
          request = BaseManagement::ManagementHttpRequest.new(:put, path, body)
          Azure::Loggerx.info "Deleting virtual machine endpoint #{endpoint_name} ..."
          request.call
        else
          Azure::Loggerx.error "Cannot find virtual machine \"#{vm_name}\" under cloud service \"#{cloud_service_name}\"."
        end
      end
    1. Fetch VM details to get the current endpoints
    1. Remove the endpoint
    1. Update "role"

Not sure what Microsoft means by "role"....

Upvotes: 0

Gaurav Mantri
Gaurav Mantri

Reputation: 136146

I don't think there's a REST API operation exclusively for deleting an endpoint. What you could do is first get the VM configuration using Get Role operation. You will get an XML. Next you could remove the endpoint setting which you wish to delete from this XML and call Update Role again to persist the setting.

Upvotes: 2

Related Questions