本文整理汇总了Golang中github.com/Azure/azure-sdk-for-go/arm/resources.GroupsClient.CreateOrUpdate方法的典型用法代码示例。如果您正苦于以下问题:Golang GroupsClient.CreateOrUpdate方法的具体用法?Golang GroupsClient.CreateOrUpdate怎么用?Golang GroupsClient.CreateOrUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Azure/azure-sdk-for-go/arm/resources.GroupsClient
的用法示例。
在下文中一共展示了GroupsClient.CreateOrUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: initResourceGroup
// initResourceGroup creates and initialises a resource group for this
// environment. The resource group will have a storage account and a
// subnet associated with it (but not necessarily contained within:
// see subnet creation).
func (env *azureEnviron) initResourceGroup() (*config.Config, error) {
location := env.config.location
tags, _ := env.config.ResourceTags()
resourceGroupsClient := resources.GroupsClient{env.resources}
logger.Debugf("creating resource group %q", env.resourceGroup)
_, err := resourceGroupsClient.CreateOrUpdate(env.resourceGroup, resources.Group{
Location: to.StringPtr(location),
Tags: toTagsPtr(tags),
})
if err != nil {
return nil, errors.Annotate(err, "creating resource group")
}
var vnetPtr *network.VirtualNetwork
if env.resourceGroup == env.controllerResourceGroup {
// Create an internal network for all VMs to connect to.
vnetPtr, err = createInternalVirtualNetwork(
env.network, env.controllerResourceGroup, location, tags,
)
if err != nil {
return nil, errors.Annotate(err, "creating virtual network")
}
} else {
// We're creating a hosted environment, so we need to fetch
// the virtual network to create a subnet below.
vnetClient := network.VirtualNetworksClient{env.network}
vnet, err := vnetClient.Get(env.controllerResourceGroup, internalNetworkName)
if err != nil {
return nil, errors.Annotate(err, "getting virtual network")
}
vnetPtr = &vnet
}
_, err = createInternalSubnet(
env.network, env.resourceGroup, env.controllerResourceGroup,
vnetPtr, location, tags,
)
if err != nil {
return nil, errors.Annotate(err, "creating subnet")
}
// Create a storage account for the resource group.
storageAccountsClient := storage.AccountsClient{env.storage}
storageAccountName, storageAccountKey, err := createStorageAccount(
storageAccountsClient, env.config.storageAccountType,
env.resourceGroup, location, tags,
env.provider.config.StorageAccountNameGenerator,
)
if err != nil {
return nil, errors.Annotate(err, "creating storage account")
}
return env.config.Config.Apply(map[string]interface{}{
configAttrStorageAccount: storageAccountName,
configAttrStorageAccountKey: storageAccountKey,
})
}
示例2: initResourceGroup
// initResourceGroup creates and initialises a resource group for this
// environment. The resource group will have a storage account and a
// subnet associated with it (but not necessarily contained within:
// see subnet creation).
func (env *azureEnviron) initResourceGroup() (*config.Config, error) {
location := env.config.location
tags := tags.ResourceTags(
names.NewModelTag(env.config.Config.UUID()),
names.NewModelTag(env.config.Config.ControllerUUID()),
env.config,
)
resourceGroupsClient := resources.GroupsClient{env.resources}
logger.Debugf("creating resource group %q", env.resourceGroup)
_, err := resourceGroupsClient.CreateOrUpdate(env.resourceGroup, resources.Group{
Location: to.StringPtr(location),
Tags: toTagsPtr(tags),
})
if err != nil {
return nil, errors.Annotate(err, "creating resource group")
}
// Create an internal network for all VMs in the
// resource group to connect to.
vnetPtr, err := createInternalVirtualNetwork(
env.network, env.resourceGroup, location, tags,
)
if err != nil {
return nil, errors.Annotate(err, "creating virtual network")
}
_, err = createInternalSubnet(
env.network, env.resourceGroup, vnetPtr, location, tags,
)
if err != nil {
return nil, errors.Annotate(err, "creating subnet")
}
// Create a storage account for the resource group.
storageAccountsClient := storage.AccountsClient{env.storage}
storageAccountName, storageAccountKey, err := createStorageAccount(
storageAccountsClient, env.config.storageAccountType,
env.resourceGroup, location, tags,
env.provider.config.StorageAccountNameGenerator,
)
if err != nil {
return nil, errors.Annotate(err, "creating storage account")
}
return env.config.Config.Apply(map[string]interface{}{
configAttrStorageAccount: storageAccountName,
configAttrStorageAccountKey: storageAccountKey,
})
}