2

Given this method signature:

func (client LoadBalancersClient) Get(ctx context.Context, resourceGroupName string, loadBalancerName string, expand string) (result LoadBalancer, err error)

How does one use the "expand" parameter? There appears to be zero documentation on how to format it and all I'm getting is InvalidExpandQueryOptionValue errors.

lbClient := network.NewLoadBalancersClient(subId)
lbClient.Authorizer = authr

lbResult, err := lbClient.Get(context.TODO(), rgName, lbName, "loadBalancingRules")
if err != nil {
    panic(err)
}

Results in:

panic: network.LoadBalancersClient#Get: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidExpandQueryOptionValue" Message="$expand query option value is invalid. The resource does not have property loadBalancingRules or the property does not represent a reference to another resource." Details=[]

I've also tried $loadBalancingRules, {$loadBalancingRules}, and LoadBalancingRules.

erstaples
  • 1,986
  • 16
  • 31

1 Answers1

2

I was hit by the same problem but when dealing with VNETs, Subnets and NSGs.

What happens is, when you query an object, by default, the properties of the referenced objects below in the hierarchy are not fetched. So if I were to get a list of NSGs (Network Security Groups), it would show me a list of subnets in the subnets property which would be references to subnets that are assigned to that NSG, however, the properties of those subnets like Name, ip address, etc will be set to None.

To overcome this, when querying for NSG I used

exapnd='subnets'

With this set, I can access the properties of the referenced subnets as well.

Derek Lawrence
  • 1,551
  • 2
  • 16
  • 36
Keen
  • 21
  • 3