diff --git a/README.md b/README.md index 620de7eec0..8060390eb5 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ Options: - `--azure-subscription-id`: Your Azure subscription ID. - `--azure-subscription-cert`: Your Azure subscription cert. +Note: the machine name will be used as DNS name for the Cloud Service (e.g. machinename.cloudapp.net) + ### Amazon EC2 Create machines on [Amazon Web Services](http://aws.amazon.com). You will need an Access Key ID, Secret Access Key and a VPC ID. To find the VPC ID, login to the AWS console and go to Services -> VPC -> Your VPCs. Select the one where you would like to launch the instance. diff --git a/drivers/azure/azure.go b/drivers/azure/azure.go index 4c2a1ff8a6..0ca84839d1 100644 --- a/drivers/azure/azure.go +++ b/drivers/azure/azure.go @@ -108,16 +108,7 @@ func GetCreateFlags() []cli.Flag { } func NewDriver(machineName string, storePath string, caCert string, privateKey string) (drivers.Driver, error) { - t := time.Now().Format("20060102150405") - name := fmt.Sprintf("%s-%s", machineName, t) - - // trim name to 24 chars due to the azure dns name limit - if len(name) > 24 { - name = name[0:24] - - } - - driver := &Driver{MachineName: name, storePath: storePath, CaCertPath: caCert, PrivateKeyPath: privateKey} + driver := &Driver{MachineName: machineName, storePath: storePath, CaCertPath: caCert, PrivateKeyPath: privateKey} return driver, nil } @@ -173,6 +164,20 @@ func (driver *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { } func (driver *Driver) PreCreateCheck() error { + if err := driver.setUserSubscription(); err != nil { + return err + } + + // check azure DNS to make sure name is available + available, response, err := vmClient.CheckHostedServiceNameAvailability(driver.MachineName) + if err != nil { + return err + } + + if !available { + return fmt.Errorf(response) + } + return nil }