Skip to content

Update Azure SDK For Go#11849

Closed
mmorel-35 wants to merge 6 commits intoprometheus:mainfrom
mmorel-35:github.com/Azure/azure-sdk-for-go
Closed

Update Azure SDK For Go#11849
mmorel-35 wants to merge 6 commits intoprometheus:mainfrom
mmorel-35:github.com/Azure/azure-sdk-for-go

Conversation

@mmorel-35
Copy link
Copy Markdown
Contributor

@mmorel-35 mmorel-35 commented Jan 13, 2023

Hi @xboxeer ! Hi @roidelapluie ! Hi @sandeep-sen !

This is a first attempt to fix #10942

With the help of the migration guide and the documentation of the different documentation I'm proposing this solution.

But two things are bothering me. First I add to create a Policy to override the user-Agent. Second, I had to split the Network Interface ID to extract resourceGroupName and networkInterfaceName so I can call the Get method of the NetWorkInterfacesClient.

The second method is specially risky in case of the evolution of the endpoint structure.

Do you have any idea to make this more elegant and maintainable ?

Fixes #10942

Signed-off-by: Matthieu MOREL matthieu.morel35@gmail.com

return nil, errorNotFound
}
return nil, autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", resp, "Failure responding to request")
return nil, autorest.NewErrorWithError(err, "armnetwork.InterfacesClient", "Get", nil, "Failure responding to request")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the best way to get rid of autorest completly ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it depends on your logic about error, rely on autrest to wrap error is not necessary. Our new version of SDK does not provide utility about errors, mainly because the error returned by SDK is simple.

Comment on lines 33 to 34
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those three dependencies should not be there anymore.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only left thing is error handling. As I said in previous comment, you could do anything with SDK returned error. I don't familiar with the error tracing framework of prometheus. If you need some help, feel free to give the detailed questions.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Comment on lines +198 to +205
cloudConfig := cloud.Configuration{
ActiveDirectoryAuthorityHost: env.ActiveDirectoryEndpoint, Services: map[cloud.ServiceName]cloud.ServiceConfiguration{
cloud.ResourceManager: {
Audience: env.ServiceManagementEndpoint,
Endpoint: env.ResourceManagerEndpoint,
},
},
}
Copy link
Copy Markdown
Contributor Author

@mmorel-35 mmorel-35 Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tadelesh

Shall we replace the azure.EnvironmentFromName(...) with a map for cloud.Configuration like this one ?

var environments = map[string]Environment{
	"AZURECHINACLOUD":        cloud.AzureChina ,
	"AZUREGERMANCLOUD":       cloud.AzurePublic ,
	"AZURECLOUD":             cloud.AzurePublic ,
	"AZUREPUBLICCLOUD":       cloud.AzurePublic ,
	"AZUREUSGOVERNMENT":      cloud.AzureGovernment ,
	"AZUREUSGOVERNMENTCLOUD": cloud.AzureGovernment ,
}

Or Is there an already existing way to map this ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not use such environment any more in new SDK version. We have defined three common clouds' configuration in azcore. You have already used it: cloud.AzureGovernment, cloud.AzureChina, cloud.AzurePublic. I don't know whether you have exposed such environment settings to customer in your code, if so, then the mapping is fine to keep consistency, else, I think you could use cloud configuration directly.

@mmorel-35 mmorel-35 marked this pull request as ready for review January 17, 2023 20:27
mmorel-35 and others added 2 commits January 17, 2023 21:32
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
@mmorel-35
Copy link
Copy Markdown
Contributor Author

Replaced by #11860

@mmorel-35 mmorel-35 closed this Jan 18, 2023
@mmorel-35 mmorel-35 deleted the github.com/Azure/azure-sdk-for-go branch January 18, 2023 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move away from deprecated Azure packages.

2 participants