From 8dc40af2d3d52424670802c317e3624dba73519b Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Fri, 7 Jun 2013 16:04:44 -0700 Subject: [PATCH] Upgrading Azure solutions to SDK 2.0 --HG-- branch : 1.x extra : rebase_source : 9268657065fe85a15a09c4cab0b5edbacee0e6a1 --- AzurePackage.proj | 5 +-- .../Orchard.Azure.Tests.csproj | 1 - src/Orchard.Azure/AzureFileSystem.cs | 4 +-- .../Media/AzureBlobStorageProvider.cs | 18 ++++++++++ src/Orchard.Azure/Logging/AzureAppender.cs | 23 +++++------- .../Orchard.Azure.CloudService.ccproj | 4 +-- .../ServiceConfiguration.cscfg | 2 +- .../ServiceDefinition.csdef | 2 +- .../Orchard.Azure.Web.csproj | 12 ++++--- .../Orchard.Azure.Web/Web.config | 2 +- src/Orchard.Azure/Orchard.Azure.csproj | 4 ++- src/Orchard.Azure/Orchard.Azure.sln | 35 +++++++++++++++++++ 12 files changed, 82 insertions(+), 30 deletions(-) diff --git a/AzurePackage.proj b/AzurePackage.proj index 4d99cdffa..800f80004 100644 --- a/AzurePackage.proj +++ b/AzurePackage.proj @@ -16,8 +16,9 @@ - - + + + diff --git a/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj b/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj index 1285380e9..a27522516 100644 --- a/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj +++ b/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj @@ -53,7 +53,6 @@ AllRules.ruleset - True diff --git a/src/Orchard.Azure/AzureFileSystem.cs b/src/Orchard.Azure/AzureFileSystem.cs index 310964b15..af8c94e55 100644 --- a/src/Orchard.Azure/AzureFileSystem.cs +++ b/src/Orchard.Azure/AzureFileSystem.cs @@ -17,8 +17,8 @@ namespace Orchard.Azure { public string ContainerName { get; protected set; } private readonly CloudStorageAccount _storageAccount; - private readonly string _root; - private readonly string _absoluteRoot; + protected readonly string _root; + protected readonly string _absoluteRoot; public CloudBlobClient BlobClient { get; private set; } public CloudBlobContainer Container { get; private set; } diff --git a/src/Orchard.Azure/FileSystems/Media/AzureBlobStorageProvider.cs b/src/Orchard.Azure/FileSystems/Media/AzureBlobStorageProvider.cs index e4a4fdc3c..783ca8fb6 100644 --- a/src/Orchard.Azure/FileSystems/Media/AzureBlobStorageProvider.cs +++ b/src/Orchard.Azure/FileSystems/Media/AzureBlobStorageProvider.cs @@ -38,5 +38,23 @@ namespace Orchard.Azure.FileSystems.Media { } } } + + /// + /// Retrieves the local path for a given url within the storage provider. + /// + /// The public url of the media. + /// The local path. + public string GetLocalPath(string url) { + if (url.StartsWith(_absoluteRoot)) { + return url.Substring(_absoluteRoot.Length); + } + + return url; + } + + public string GetRelativePath(string path) { + return GetPublicUrl(path); + } + } } \ No newline at end of file diff --git a/src/Orchard.Azure/Logging/AzureAppender.cs b/src/Orchard.Azure/Logging/AzureAppender.cs index e5fc5d261..a7eccdbd5 100644 --- a/src/Orchard.Azure/Logging/AzureAppender.cs +++ b/src/Orchard.Azure/Logging/AzureAppender.cs @@ -1,7 +1,5 @@ using System; -using Microsoft.WindowsAzure; -using Microsoft.WindowsAzure.Diagnostics.Management; -using Microsoft.WindowsAzure.ServiceRuntime; +using Microsoft.WindowsAzure.Diagnostics; using log4net.Appender; using log4net.Core; @@ -13,21 +11,16 @@ namespace Orchard.Azure.Logging { /// public class AzureAppender : AppenderSkeleton { private const string WadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"; - public AzureAppender() { - var cloudStorageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(WadConnectionString)); + var defaultDiagnostics = DiagnosticMonitor.GetDefaultInitialConfiguration(); + var period = TimeSpan.FromMinutes(1d); + + defaultDiagnostics.Directories.ScheduledTransferPeriod = period; + defaultDiagnostics.Logs.ScheduledTransferPeriod = period; + defaultDiagnostics.WindowsEventLog.ScheduledTransferPeriod = period; - var roleInstanceDiagnosticManager = cloudStorageAccount.CreateRoleInstanceDiagnosticManager( - RoleEnvironment.DeploymentId, - RoleEnvironment.CurrentRoleInstance.Role.Name, - RoleEnvironment.CurrentRoleInstance.Id); - - var diagnosticMonitorConfiguration = roleInstanceDiagnosticManager.GetCurrentConfiguration(); - diagnosticMonitorConfiguration.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1d); - diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1d); - - roleInstanceDiagnosticManager.SetCurrentConfiguration(diagnosticMonitorConfiguration); + DiagnosticMonitor.Start(WadConnectionString, defaultDiagnostics); } protected override void Append(LoggingEvent loggingEvent) { diff --git a/src/Orchard.Azure/Orchard.Azure.CloudService/Orchard.Azure.CloudService.ccproj b/src/Orchard.Azure/Orchard.Azure.CloudService/Orchard.Azure.CloudService.ccproj index e38bf903d..ec849330b 100644 --- a/src/Orchard.Azure/Orchard.Azure.CloudService/Orchard.Azure.CloudService.ccproj +++ b/src/Orchard.Azure/Orchard.Azure.CloudService/Orchard.Azure.CloudService.ccproj @@ -4,7 +4,7 @@ Debug AnyCPU - 1.8 + 2.0 {03c5327d-4e8e-45a7-acd1-e18e7caa3c4a} Library Properties @@ -54,7 +54,7 @@ 10.0 - $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Windows Azure Tools\1.8\ + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Windows Azure Tools\2.0\ \ No newline at end of file diff --git a/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceConfiguration.cscfg b/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceConfiguration.cscfg index 7325bf518..aec004893 100644 --- a/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceConfiguration.cscfg +++ b/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceConfiguration.cscfg @@ -1,5 +1,5 @@  - + diff --git a/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceDefinition.csdef b/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceDefinition.csdef index 2745980d2..a0185fefe 100644 --- a/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceDefinition.csdef +++ b/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceDefinition.csdef @@ -1,5 +1,5 @@  - + diff --git a/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj b/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj index 049cfacc7..47d532672 100644 --- a/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj +++ b/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj @@ -65,13 +65,13 @@ False C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-10\ref\Microsoft.WindowsAzure.Configuration.dll - - False + C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-10\ref\Microsoft.WindowsAzure.Diagnostics.dll - - True + + False + ..\..\..\lib\newtonsoft.json\Newtonsoft.Json.dll @@ -267,6 +267,10 @@ {642A49D7-8752-4177-80D6-BFBBCFAD3DE0} Orchard.Forms + + {1f0b6b85-8b0b-47ca-899d-f25b4f1b52c3} + Orchard.ImageEditor + {fe5c5947-d2d5-42c5-992a-13d672946135} Orchard.ImportExport diff --git a/src/Orchard.Azure/Orchard.Azure.Web/Web.config b/src/Orchard.Azure/Orchard.Azure.Web/Web.config index 8390d8232..1321969c7 100644 --- a/src/Orchard.Azure/Orchard.Azure.Web/Web.config +++ b/src/Orchard.Azure/Orchard.Azure.Web/Web.config @@ -42,7 +42,7 @@ - diff --git a/src/Orchard.Azure/Orchard.Azure.csproj b/src/Orchard.Azure/Orchard.Azure.csproj index b152d4634..e6dd6c5c9 100644 --- a/src/Orchard.Azure/Orchard.Azure.csproj +++ b/src/Orchard.Azure/Orchard.Azure.csproj @@ -112,7 +112,9 @@ true - + + +