How to assign custom domain to Azure VM

  • In Azure, create DNS Zone with custom domain name
  • Check name servers of above Zone, and copy them to Domains’s CPanel name servers
  • Add 2 DNS records to Zone (created in step 1) with IP points to Azure VM’s Public static IP as shown below
    • @
    • *
  • (Maybe this step is optional, need to check again!)
    Add CNAME severs in Domains’s CPanel with value = DNS of Azure VM
  • Change wp_options table in DB with 2 URL points to custom domain name correctly (if using WP site)

Compress + Encode Java String

public String compressEncodeData(String data) throws IOException {
long startCompressTime = System.currentTimeMillis();
ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length());
GZIPOutputStream gzip = new GZIPOutputStream(bos);
gzip.write(data.getBytes());
gzip.close();
byte[] compressed = bos.toByteArray();
bos.close();
long endCompressTime = System.currentTimeMillis();
String encodedString = Base64.getEncoder().encodeToString(compressed);
long endEndcodeTime = System.currentTimeMillis();
VdtLogger.getInstance().getLog().info(String.format(“[VDT] Compress time: %s – Encode time: %s – Total time: %s”,
endCompressTime – startCompressTime, endEndcodeTime – endCompressTime, endEndcodeTime – startCompressTime));
return encodedString;
}

/**
* De code decompress data.
*
* @param data the data
* @return the string
* @throws IOException Signals that an I/O exception has occurred.
*/
public static String decodeDecompressData(String data) throws IOException {
System.out.println(“[VDT] Data part length: “+ data.length());
System.out.println(“[VDT] Data part: “+ data);
long startDecodeTime = System.currentTimeMillis();
byte[] decoded = Base64.getDecoder().decode(data);
long endDecodeTime = System.currentTimeMillis();
ByteArrayInputStream bis = new ByteArrayInputStream(decoded);
GZIPInputStream gis = new GZIPInputStream(bis);
BufferedReader br = new BufferedReader(new InputStreamReader(gis, “UTF-8”));
StringBuilder sb = new StringBuilder();
String line;
while((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
gis.close();
bis.close();
String decompressed = sb.toString();
long endDecompressTime = System.currentTimeMillis();
System.out.println(“[VDT] Decode length: ” + decoded.length);
System.out.println(“[VDT] Decompress length: ” + decompressed.length());
System.out.println(String.format(“[VDT] Decode time: %s – Decompress time: %s – Total time: %s”,
endDecodeTime – startDecodeTime, endDecompressTime – endDecodeTime, endDecompressTime – startDecodeTime));
return decompressed;
}