func resourceArmCdnProfileCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient) cdnProfilesClient := client.cdnProfilesClient log.Printf("[INFO] preparing arguments for Azure ARM CDN Profile creation.") name := d.Get("name").(string) location := d.Get("location").(string) resGroup := d.Get("resource_group_name").(string) sku := d.Get("sku").(string) tags := d.Get("tags").(map[string]interface{}) properties := cdn.ProfilePropertiesCreateParameters{ Sku: &cdn.Sku{ Name: cdn.SkuName(sku), }, } cdnProfile := cdn.ProfileCreateParameters{ Location: &location, Properties: &properties, Tags: expandTags(tags), } resp, err := cdnProfilesClient.Create(name, cdnProfile, resGroup) if err != nil { return err } d.SetId(*resp.ID) log.Printf("[DEBUG] Waiting for CDN Profile (%s) to become available", name) stateConf := &resource.StateChangeConf{ Pending: []string{"Accepted", "Updating", "Creating"}, Target: []string{"Succeeded"}, Refresh: cdnProfileStateRefreshFunc(client, resGroup, name), Timeout: 10 * time.Minute, } if _, err := stateConf.WaitForState(); err != nil { return fmt.Errorf("Error waiting for CDN Profile (%s) to become available: %s", name, err) } return resourceArmCdnProfileRead(d, meta) }
func resourceArmCdnProfileCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient) cdnProfilesClient := client.cdnProfilesClient log.Printf("[INFO] preparing arguments for Azure ARM CDN Profile creation.") name := d.Get("name").(string) location := d.Get("location").(string) resGroup := d.Get("resource_group_name").(string) sku := d.Get("sku").(string) tags := d.Get("tags").(map[string]interface{}) properties := cdn.ProfilePropertiesCreateParameters{ Sku: &cdn.Sku{ Name: cdn.SkuName(sku), }, } cdnProfile := cdn.ProfileCreateParameters{ Location: &location, Properties: &properties, Tags: expandTags(tags), } _, err := cdnProfilesClient.Create(name, cdnProfile, resGroup, make(chan struct{})) if err != nil { return err } read, err := cdnProfilesClient.Get(name, resGroup) if err != nil { return err } if read.ID == nil { return fmt.Errorf("Cannot read CND Profile %s (resource group %s) ID", name, resGroup) } d.SetId(*read.ID) return resourceArmCdnProfileRead(d, meta) }