@@ -13,14 +13,24 @@ The `armautomanage` module provides operations for working with Azure Automanage
13
13
- an [ Azure subscription] ( https://azure.microsoft.com/free/ )
14
14
- Go 1.18 or above
15
15
16
- ## Install the package
16
+ ## Install and import required packages
17
17
18
18
This project uses [ Go modules] ( https://github.com/golang/go/wiki/Modules ) for versioning and dependency management.
19
19
20
- Install the Azure Automanage module :
20
+ Install the Azure Automanage and Azure Identity modules :
21
21
22
22
``` sh
23
- go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/automanage/armautomanage
23
+ go get " github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/automanage/armautomanage"
24
+ go get " github.com/Azure/azure-sdk-for-go/sdk/azidentity"
25
+ ```
26
+
27
+ Import the Azure Automanage and Azure Identity modules:
28
+
29
+ ``` go
30
+ import (
31
+ " github.com/Azure/azure-sdk-for-go/sdk/azidentity"
32
+ " github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/automanage/armautomanage"
33
+ )
24
34
```
25
35
26
36
## Authorization
@@ -38,7 +48,9 @@ For more information on authentication, please see the documentation for `aziden
38
48
Azure Automanage modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential.
39
49
40
50
``` go
41
- client , err := armautomanage.NewReportsClient (<subscription ID >, cred, nil )
51
+ reportsClient , err := armautomanage.NewReportsClient (" <subscription ID>" , cred, nil )
52
+ configProfilesClient , err := armautomanage.NewConfigurationProfilesClient (" <subscription ID>" , cred, nil )
53
+ assignmentClient , err := armautomanage.NewConfigurationProfileAssignmentsClient (" <subscription ID>" , cred, nil )
42
54
```
43
55
44
56
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 ) .
@@ -49,9 +61,109 @@ options := arm.ClientOptions {
49
61
Cloud: cloud.AzureChina ,
50
62
},
51
63
}
52
- client , err := armautomanage.NewReportsClient (<subscription ID >, cred, &options)
64
+ reportsClient , err := armautomanage.NewReportsClient (" <subscription ID>" , cred, &options)
65
+ ```
66
+
67
+ ## Create or Update a Custom Automanage Configuration Profile
68
+
69
+ To update a profile, provide a value for all properties as if you were creating a configuration profile (ID, Name, Type, Location, Properties, Tags)
70
+
71
+ ``` go
72
+ configuration := map [string ]interface {}{
73
+ " Antimalware/Enable" : false ,
74
+ " AzureSecurityCenter/Enable" : true ,
75
+ " Backup/Enable" : false ,
76
+ " BootDiagnostics/Enable" : true ,
77
+ " ChangeTrackingAndInventory/Enable" : true ,
78
+ " GuestConfiguration/Enable" : true ,
79
+ " LogAnalytics/Enable" : true ,
80
+ " UpdateManagement/Enable" : true ,
81
+ " VMInsights/Enable" : true ,
82
+ }
83
+
84
+ properties := armautomanage.ConfigurationProfileProperties {
85
+ Configuration : configuration,
86
+ }
87
+
88
+ location := " eastus"
89
+ environment := " dev"
90
+
91
+ // tags may be omitted
92
+ tags := make (map [string ]*string )
93
+ tags[" environment" ] = &environment
94
+
95
+ profile := armautomanage.ConfigurationProfile {
96
+ Location : &location,
97
+ Properties : &properties,
98
+ Tags : tags,
99
+ }
100
+
101
+ newProfile , err := configProfilesClient.CreateOrUpdate (context.Background (), configurationProfileName, " resourceGroupName" , profile, nil )
102
+ ```
103
+
104
+
105
+ ## Get an Automanage Configuration Profile
106
+
107
+ ``` go
108
+ profile , err := configProfilesClient.Get (context.Background (), " configurationProfileName" , " resourceGroupName" , nil )
109
+ data , err := json.MarshalIndent (profile, " " , " " )
110
+
111
+ fmt.Println (string (data))
112
+ ```
113
+
114
+
115
+ ## Delete an Automanage Configuration Profile
116
+
117
+ ``` go
118
+ _ , err := configProfilesClient.Delete (context.Background (), " resourceGroupName" , " configurationProfileName" , nil )
119
+ ```
120
+
121
+
122
+ ## Get an Automanage Profile Assignment
123
+
124
+ ``` go
125
+ assignment , err := assignmentClient.Get (context.Background (), " resourceGroupName" , " default" , " vmName" , nil )
126
+ data , err := json.MarshalIndent (assignment, " " , " " )
127
+ fmt.Println (string (data))
128
+ ```
129
+
130
+
131
+ ## Create an Assignment between a VM and an Automanage Best Practices Production Configuration Profile
132
+
133
+ ``` go
134
+ configProfileId := " /providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"
135
+
136
+ properties := armautomanage.ConfigurationProfileAssignmentProperties {
137
+ ConfigurationProfile : &configProfileId,
138
+ }
139
+
140
+ assignment := armautomanage.ConfigurationProfileAssignment {
141
+ Properties : &properties,
142
+ }
143
+
144
+ // assignment name must be 'default'
145
+ newAssignment, err = assignmentClient.CreateOrUpdate (context.Background (), " default" , " resourceGroupName" , " vmName" , assignment, nil )
53
146
```
54
147
148
+
149
+ ## Create an Assignment between a VM and a Custom Automanage Configuration Profile
150
+
151
+ ``` go
152
+ configProfileId := " /subscriptions/<subscription ID>/resourceGroups/resourceGroupName/providers/Microsoft.Automanage/configurationProfiles/configurationProfileName"
153
+
154
+ properties := armautomanage.ConfigurationProfileAssignmentProperties {
155
+ ConfigurationProfile : &configProfileId,
156
+ }
157
+
158
+ assignment := armautomanage.ConfigurationProfileAssignment {
159
+ Properties : &properties,
160
+ }
161
+
162
+ // assignment name must be 'default'
163
+ newAssignment, err = assignmentClient.CreateOrUpdate (context.Background (), " default" , " resourceGroupName" , " vmName" , assignment, nil )
164
+ ```
165
+
166
+
55
167
## Provide Feedback
56
168
57
169
If you encounter bugs or have suggestions, please
0 commit comments