duanjiao6731 2016-04-22 14:51
浏览 75

如何使用GoLang API在Azure中创建虚拟网络?

Currently I am trying to create Virtual Network using the GoLang code:

client := network.NewVirtualNetworksClient(subscriptionID)
var parameters network.VirtualNetwork
c := make(<-chan struct{})

c1, err := client.CreateOrUpdate(resourceGroupName, virtualNetworkName, parameters, c)

utils.Info.Println(err.Error())
utils.Info.Println(c1)

But the code isn't working fine. It throws the following exception:

Failure sending request: StatusCode=401 -- Original Error: Long running operation terminated with status 'Failed': Code="AuthenticationFailed" Message="Authentication failed. The 'Authorization' header is missing."

Your help will be highly appreciated.

  • 写回答

2条回答 默认 最新

  • dongsheng4679 2016-04-22 16:17
    关注

    I assume you use GoLang SDK for Azure ? The reason of the error is that when you make a request, it does not have the Authorization header. Authorization header is the JSON Web Token that you can obtain from Azure Active Directory

    1) Take a look at the request in the Fiddler and see if your request is aligned with the rules.

    2) Go with the tutorials about how to get the token (1 and 2).

    评论

报告相同问题?