github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/README.md (about) 1 # Azure Network Module for Go 2 3 The `armnetwork` module provides operations for working with Azure Network. 4 5 [Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/network/armnetwork) 6 7 # Getting started 8 9 ## Prerequisites 10 11 - an [Azure subscription](https://azure.microsoft.com/free/) 12 - Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) 13 14 ## Install the package 15 16 This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. 17 18 Install the Azure Network module: 19 20 ```sh 21 go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6 22 ``` 23 24 ## Authorization 25 26 When creating a client, you will need to provide a credential for authenticating with Azure Network. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. 27 28 ```go 29 cred, err := azidentity.NewDefaultAzureCredential(nil) 30 ``` 31 32 For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). 33 34 ## Client Factory 35 36 Azure Network module consists of one or more clients. We provide a client factory which could be used to create any client in this module. 37 38 ```go 39 clientFactory, err := armnetwork.NewClientFactory(<subscription ID>, cred, nil) 40 ``` 41 42 You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). 43 44 ```go 45 options := arm.ClientOptions { 46 ClientOptions: azcore.ClientOptions { 47 Cloud: cloud.AzureChina, 48 }, 49 } 50 clientFactory, err := armnetwork.NewClientFactory(<subscription ID>, cred, &options) 51 ``` 52 53 ## Clients 54 55 A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. 56 57 ```go 58 client := clientFactory.NewAdminRuleCollectionsClient() 59 ``` 60 61 ## Fakes 62 63 The fake package contains types used for constructing in-memory fake servers used in unit tests. 64 This allows writing tests to cover various success/error conditions without the need for connecting to a live service. 65 66 Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. 67 68 ## More sample code 69 70 - [Creating a Fake](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/network/armnetwork/fake_example_test.go) 71 - [IP Address](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/network/ipaddress) 72 - [Load Balancer](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/network/loadbalancer) 73 - [Network Interface](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/network/networkInterface) 74 - [Security Group](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/network/securitygroups) 75 - [Subnet](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/network/subnets) 76 - [Virtual Network](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/network/virtualnetwork) 77 78 ## Provide Feedback 79 80 If you encounter bugs or have suggestions, please 81 [open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Network` label. 82 83 # Contributing 84 85 This project welcomes contributions and suggestions. Most contributions require 86 you to agree to a Contributor License Agreement (CLA) declaring that you have 87 the right to, and actually do, grant us the rights to use your contribution. 88 For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). 89 90 When you submit a pull request, a CLA-bot will automatically determine whether 91 you need to provide a CLA and decorate the PR appropriately (e.g., label, 92 comment). Simply follow the instructions provided by the bot. You will only 93 need to do this once across all repos using our CLA. 94 95 This project has adopted the 96 [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 97 For more information, see the 98 [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 99 or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any 100 additional questions or comments.