本文整理匯總了Golang中github.com/Azure/azure-sdk-for-go/arm.Client.ResourceGroups方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.ResourceGroups方法的具體用法?Golang Client.ResourceGroups怎麽用?Golang Client.ResourceGroups使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Azure/azure-sdk-for-go/arm.Client
的用法示例。
在下文中一共展示了Client.ResourceGroups方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createResourceGroup
func createResourceGroup(
name, location string,
arm arm.Client) (group resources.ResourceGroup, err error) {
rgc := arm.ResourceGroups()
rpc := arm.Providers()
params := resources.ResourceGroup{Name: &name, Location: &location}
group, err = rgc.CreateOrUpdate(name, params)
if err != nil {
err = fmt.Errorf("Failed to create resource group '%s' in location '%s': '%s'\n", name, location, err.Error())
return
}
fmt.Printf("Created resource group '%s'\n", *group.Name)
if _, err1 := rpc.Register("Microsoft.Storage"); err != nil {
err = fmt.Errorf("Failed to register resource provider 'Microsoft.Storage': '%s'\n", err1.Error())
}
if _, err1 := rpc.Register("Microsoft.Network"); err != nil {
err = fmt.Errorf("Failed to register resource provider 'Microsoft.Network': '%s'\n", err1.Error())
}
if _, err1 := rpc.Register("Microsoft.Compute"); err != nil {
err = fmt.Errorf("Failed to register resource provider 'Microsoft.Compute': '%s'\n", err1.Error())
}
return
}
示例2: createResourceGroup
func createResourceGroup(name, location string, arm arm.Client) (group resources.ResourceGroup, err error) {
rgc := arm.ResourceGroups()
params := resources.ResourceGroup{Name: &name, Location: &location}
group, err = rgc.CreateOrUpdate(name, params)
if err != nil {
err = fmt.Errorf("Failed to create resource group '%s' in location '%s': '%s'\n", name, location, err.Error())
return
}
fmt.Printf("Created resource group '%s'\n", *group.Name)
return
}