another technical blog...technically

Friday, November 21, 2014

Provision a SharePoint 2013 farm with Azure and PowerShell

I begun to work on Azure one year ago in order to have a dev SharePoint 2013 to build some code since i don't have a powerful PC.
Reading below articles, i was able to create my personal farm
Step-by-Step: Build a FREE SharePoint 2013 Dev/Test Lab in the Cloud with Windows Azure Infrastructure Services - Part 1
Step-by-Step: Build a FREE SharePoint 2013 Dev/Test Lab in the Cloud with Windows Azure Infrastructure Services - Part 2
A colleague (codename Roller) asked me if it was possible to build the farm automagically using PowerShell, since there were amazing PowerShell Azure cmdlets.
<< Varro, why don't you do something like that? it would be so useful >>
<< Ok Roller, but it will take a lot of my free time, you'll give me money for this? >>
<< No >>
<< Ok Roller, i'll do it for you ... someday... in the future >>
That day is arrived.
/mode joke off
Since i need something simple and smart to build a SP2013 farm, i started surfing the web studying (and also stealing code) creating this wonderful script you can download clicking here.

Requirements
Once you downloaded the script on you PC you have to read the README (do it).
It explains what do you need to make script execution smooth (maybe).
  1. Enable PSRemoting on your PC: this will be useful to use CredSSP to invoke remote PowerShell script execution on Azure machine (it will avoid the double hop problem); since you have to allow PSRemoting to *.cloudapp.net you are future-powershell-experiments proof.
  2. Download Azure cmdlets
  3. Download your Azure account publish settings (have you got a Azure account uh?).
  4. Configure XML file
The zip contains a Config - example.xml

 
 
 
  
  
 
 
 
  
 
 
  
   
  
  
   
  
  
   
   
  
 

If you don't want to waste you time, simply change "MSDN subscription name" with your MSDN subscription name, passwords (substitute Password01 with your preferred one) and substitute "sharepointLab01" prefix with something else (please note that resulting vm name length must be less than 15 characters).
Note that if you are behind proxyes, firewall and other stuffs, you could have troubles.
Please take some minutes to read the FAQ below, since you'll need it, after thas warm-up phase, simply run BuildEnvironment.ps1

FAQ.
Q1: What is the average execution time of the batch script?
A1: The farm will be provisioned approximately in 1 hour, i could make it quicker, better, safer... but you have the code, make it better :) .

Q2: The script is someway interactive?
A2: No, you will be prompted to proceed to WinRM quick configuration just one time, when provisioning SharePoint VM, click y and everything will be fine


Q3: I noticed the script sometimes stop itself and give me some error, what i have to do?
A3: Simply solve the errors and re-run the script: already done steps will be bybassed if possible

Q4: I received this error: "Connecting to remote server failed with the following message: The client cannot connect to the destination specified in the request blablabla" what i have to do?
A4: Just keep calm and re-run the script. This error means the script is unable to connect to the VM, so if you're ok with firewall, proxyes and other security stuffs, the connection simply failed, try again.
If the problem persists, try something more rude, delete the VM giving problems and re-run the scipt.

Q5: Are there some built-in users?
A5: Yes sir, SPFarm, which is also the farm admin and SPServiceApp

Q6:What about the service application?
A6: The script provisions User Profile, Managed Metadata and Search service applications, but you can do che quick wizard whenever you want if you need more

Happy ending (hope so)
Download the code from here and have fun. 

Remember, this is not production software, it's something i use for me, myself and i, so i cannot ensure you everything is gonna be fine, even if i provisioned some farm with this, but if i'll save you time with this... come on offer me a beer ;) .

In loving memory of Roller

Sunday, November 2, 2014

OpenMap to JTS and JTS to OpenMap

Yesterday i received a newsletter about OpenMap, and i remembered university times.
I also remembered i developed a small piece of code which helped me to convert OpenMap geomertries in JTS geometries.
This was useful because Oracle DBMS uses WKT format to define spatial data, but at that time, there weren't UI components able to render directly WKT.
Therefore, it was possible to convert WKT to JTS standard format, and then use JTS to map OpenMap objects. The code is below, i hope it could be still useful :-) .

OpenMapToJTS JTSToOpenMap
package presentationLevel.converters;


import java.util.List;

import com.bbn.openmap.LatLonPoint;
import com.bbn.openmap.omGraphics.OMGraphic;
import com.bbn.openmap.omGraphics.OMGraphicList;
import com.bbn.openmap.omGraphics.OMPoint;
import com.bbn.openmap.omGraphics.OMPoly;
import com.bbn.openmap.proj.Ellipsoid;
import com.bbn.openmap.proj.coords.UTMPoint;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;

public class JTSToOpenMap {

 public static OMGraphicList createOMGraphicList(List l){
  OMGraphicList oml = new OMGraphicList();
  for (Geometry g : l)
   oml.add(createOMGraphic(g));
  return oml;
 }

 public static OMGraphic createOMGraphic(Geometry g){
  if (g instanceof Point)
   return createPoint((Point) g);
  else if (g instanceof LineString)
   return createLine((LineString) g);
  else if (g instanceof Polygon)
   return createPolygon((Polygon) g);
  else
   return null;
 }

 private static OMPoint createPoint(Point p){
  float[] coordinates = coordinatesConverter(p.getCoordinates());
  OMPoint omp = new OMPoint(coordinates[0], coordinates[1]);
  return omp;
 }

 private static OMPoly createLine(LineString l){
  OMPoly omp = new OMPoly(coordinatesConverter(l.getCoordinates()), OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_STRAIGHT);
  return omp;
 }

 private static OMPoly createPolygon(Polygon p){
  OMPoly omp = new OMPoly(coordinatesConverter(p.getCoordinates()), OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_STRAIGHT);
  omp.setIsPolygon(true);
  return omp;
 }

 private static float[] coordinatesConverter(Coordinate[] c){
  float[] coordinates = new float[(c.length)*2];
  for (int i = 0, j = 0; i < c.length; i++, j = j+2){
   LatLonPoint lp = UTMPoint.UTMtoLL(Ellipsoid.WGS_84, (float) c[i].y, (float) c[i].x, 19, false, null);
            coordinates[j] = lp.getLatitude();
            coordinates[j+1] = lp.getLongitude();
  }
  return coordinates;
 }

}
Share:

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?