drivers/azure/azureutil/azureutil.go
func extractStorageAccountFromVHDURL(vhdURL string) (string, string) {
	u, err := url.Parse(vhdURL)
	if err != nil {
		log.Warn(fmt.Sprintf("URL parse error: %v", err), logutil.Fields{"url": vhdURL})
		return "", ""
	}
	parts := strings.SplitN(u.Host, ".", 2)
	if len(parts) != 2 {
		log.Warnf("Could not split account name and storage base URL: %s", vhdURL)
		return "", ""
	}
	return parts[0], strings.TrimPrefix(parts[1], "blob.") // "blob." prefix will added by azure storage sdk
}
func extractStorageAccountFromVHDURL(vhdURL string) (string, string) {
	u, err := url.Parse(vhdURL)
	if err != nil {
		log.Warn(fmt.Sprintf("URL parse error: %v", err), logutil.Fields{"url": vhdURL})
		return "", ""
	}
	parts := strings.SplitN(u.Host, ".", 2)
	if len(parts) != 2 {
		log.Warnf("Could not split account name and storage base URL: %s", vhdURL)
		return "", ""
	}
	return parts[0], strings.TrimPrefix(parts[1], "blob.") // "blob." prefix will added by azure storage sdk
}
func extractStorageAccountFromVHDURL ( vhdURL string ) ( string , string ) { u , err := url . Parse ( vhdURL ) if err != nil { log . Warn ( fmt . Sprintf ( " " , err ) , logutil . Fields { " " : vhdURL } ) return " " , " " } parts := strings . SplitN ( u . Host , " " , 2 ) if len ( parts ) != 2 { log . Warnf ( " " , vhdURL ) return " " , " " } return parts [ 0 ] , strings . TrimPrefix ( parts [ 1 ] , " " ) // "blob." prefix will added by azure storage sdk }
// extractStorageAccountFromVHDURL parses a blob URL and extracts the Azure
// Storage account name from the URL, namely first subdomain of the hostname and
// the Azure Storage service base URL (e.g. core.windows.net). If it could not
// be parsed, returns empty string.
extractStorageAccountFromVHDURL parses a blob URL and extracts the Azure Storage account name from the URL namely first subdomain of the hostname and the Azure Storage service base URL ( e . g . core . windows . net ) . If it could not be parsed returns empty string .