Azure / azure-sdk-for-go

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
https://docs.microsoft.com/azure/developer/go/
MIT License
1.62k stars 822 forks source link

expected element type <NetworkSecurityGroup> but have <NetworkSecurityGroups> #1971

Closed dcopenhaver closed 6 years ago

dcopenhaver commented 6 years ago

Hello,

"github.com/Azure/azure-sdk-for-go/services/classic/management" "github.com/Azure/azure-sdk-for-go/services/classic/management/networksecuritygroup"

` qaMSDNSubID := "your azure sub id"

certBytes, err := ioutil.ReadFile("/path/to/cert.pem")
if err != nil {
    fmt.Println("Error reading file:")
    log.Fatal(err)
}

classicClient, err := management.NewClient(qaMSDNSubID, certBytes)
if err != nil {
    fmt.Println("Error creating management client:")
    log.Fatal(err)
}

classicNSGClient := networksecuritygroup.NewClient(classicClient)

classicNSGList, err := classicNSGClient.ListNetworkSecurityGroups()
if err != nil {
    fmt.Println("Error getting list of NSG's:")
    log.Fatal(err)
}`

call to ListNetworkSecurityGroups() results in the following error: "expected element type <NetworkSecurityGroup> but have <NetworkSecurityGroups>"

I'm able to loop through other things like hostedservices using the same cert and approach etc... I'm assuming this may be a bug on your end? I know it's azure 'classic' and believe me I don't want to be working with it but I'm glad support for it in sdk's is being continued as a great use case is for querying the old api to create reports for the purposes of what 'classic' resources are still out there that need to be migrated to ARM! - kind of an aside note there... anyway, bug? I mean I'm calling a function, whatever it returns should simply be assigned to the variable(s)...

Regards, djc

jhendrixMSFT commented 6 years ago

Hello @dcopenhaver thanks for reporting this, I have a fix ready https://github.com/Azure/azure-sdk-for-go/pull/1980, would you mind trying it out to ensure it resolves your issue? It worked in my local testing.

dcopenhaver commented 6 years ago

Hello @jhendrixMSFT - Fix verified on my end. Thanks!

jhendrixMSFT commented 6 years ago

Thanks for verifying, the fix is in https://github.com/Azure/azure-sdk-for-go/releases/tag/v17.2.0.