public virtual PSApplicationPackage UploadAndActivateApplicationPackage(
string resourceGroupName,
string accountName,
string applicationId,
string version,
string filePath,
string format,
bool activateOnly)
{
if (string.IsNullOrEmpty(resourceGroupName))
{
// use resource mgr to see if account exists and then use resource group name to do the actual lookup
resourceGroupName = GetGroupForAccount(accountName);
}
if (activateOnly)
{
// If the package has already been uploaded but wasn't activated.
ActivateApplicationPackage(resourceGroupName, accountName, applicationId, version, format, Resources.FailedToActivate);
}
else
{
if (string.IsNullOrEmpty(filePath))
{
throw new ArgumentNullException("filePath", Resources.NewApplicationPackageNoPathSpecified);
}
if (!File.Exists(filePath))
{
throw new FileNotFoundException(string.Format(Resources.FileNotFound, filePath), filePath);
}
// Else create Application Package and upload.
bool appPackageAlreadyExists;
var storageUrl = GetStorageUrl(resourceGroupName, accountName, applicationId, version, out appPackageAlreadyExists);
if (appPackageAlreadyExists)
{
CheckApplicationAllowsUpdates(resourceGroupName, accountName, applicationId, version);
}
UploadFileToApplicationPackage(resourceGroupName, accountName, applicationId, version, filePath, storageUrl, appPackageAlreadyExists);
ActivateApplicationPackage(resourceGroupName, accountName, applicationId, version, format, Resources.UploadedApplicationButFailedToActivate);
}
return GetApplicationPackage(resourceGroupName, accountName, applicationId, version);
}