public virtual PSTable CreatePSTable(CreatePSTableParameters parameters)
{
if (parameters == null)
{
throw new ArgumentNullException("parameters");
}
PSTable table = null;
Action createTable = () =>
{
table =
new PSTable(CreateOrUpdateTable(
parameters.ResourceGroupName,
parameters.DataFactoryName,
parameters.Name,
parameters.RawJsonContent))
{
ResourceGroupName = parameters.ResourceGroupName,
DataFactoryName = parameters.DataFactoryName
};
if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(table.ProvisioningState))
{
string errorMessage = table.Properties == null
? string.Empty
: table.Properties.ErrorMessage;
throw new ProvisioningFailedException(errorMessage);
}
};
if (parameters.Force)
{
// If user decides to overwrite anyway, then there is no need to check if the table exists or not.
createTable();
}
else
{
bool tableExists = CheckTableExists(parameters.ResourceGroupName, parameters.DataFactoryName,
parameters.Name);
parameters.ConfirmAction(
!tableExists, // prompt only if the table exists
string.Format(
CultureInfo.InvariantCulture,
Resources.TableExists,
parameters.Name,
parameters.DataFactoryName),
string.Format(
CultureInfo.InvariantCulture,
Resources.TableCreating,
parameters.Name,
parameters.DataFactoryName),
parameters.Name,
createTable);
}
return(table);
}