Skip to content

Commit 1b267fd

Browse files
author
nzdev
committed
Merge
2 parents 26e4aea + a74cb9a commit 1b267fd

File tree

12 files changed

+177
-159
lines changed

12 files changed

+177
-159
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ Additionally the provider can be further configured with the following applicati
8181
</appSettings>
8282
</configuration>
8383
```
84+
#### Configuration using Azure Key Vault
85+
For Azure Key Vault only the key values in the `Web.config` should use '-', rather than a '.' or ':' as shown below
86+
```xml
87+
<add key="AzureBlobFileSystem-ConnectionString-media" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
88+
<add key="AzureBlobFileSystem-ContainerName-media" value="media" />
89+
<add key="AzureBlobFileSystem-RootUrl-media" value="https://[myAccountName].blob.core.windows.net/" />
90+
<add key="AzureBlobFileSystem-MaxDays-media" value="365" />
91+
<add key="AzureBlobFileSystem-UseDefaultRoute-media" value="true" />
92+
<add key="AzureBlobFileSystem-UsePrivateContainer-media" value="false" />
93+
```
94+
95+
96+
8497

8598
### Virtual Path Provider
8699
By default the plugin will serve files transparently from your domain or serve media directly from Azure. This is made possible by using a custom [Virtual Path Provider](https://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider%28v=vs.110%29.aspx) included and automatically initialised upon application startup. This can be disabled by adding the configuration setting noted above.

appveyor.yml

Lines changed: 116 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,116 @@
1-
version: 2.0.1.{build}
2-
3-
os: Visual Studio 2019
4-
5-
cache:
6-
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified
7-
8-
configuration: Release
9-
10-
environment:
11-
# Version Suffix
12-
version_suffix: alpha
13-
14-
install:
15-
- ps: .\build\appveyor-semver.ps1
16-
- ps: .\build\check-release-version.ps1
17-
- ps: Update-AppveyorBuild -Version $Env:appveyor_version
18-
- cmd: >-
19-
cd build
20-
21-
npm install
22-
23-
node appveyor-nuspec-patch.js
24-
25-
cd..
26-
- ps: >-
27-
$msiPath = "$($env:USERPROFILE)\MicrosoftAzureStorageEmulator.msi"
28-
29-
(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/F/3/8/F3857A38-D344-43B4-8E5B-2D03489909B9/MicrosoftAzureStorageEmulator.msi', $msiPath)
30-
31-
cmd /c start /wait msiexec /i $msiPath /quiet
32-
33-
assembly_info:
34-
patch: true
35-
file: 'src\UmbracoFileSystemProviders.Azure**\AssemblyInfo.*'
36-
assembly_version: '$(appveyor_file_version)'
37-
assembly_file_version: '$(appveyor_file_version)'
38-
assembly_informational_version: '$(mssemver)'
39-
40-
build_script:
41-
- cmd: >-
42-
build-appveyor.cmd
43-
44-
cd..
45-
46-
before_test:
47-
- cmd: '"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" start'
48-
# Turn tests off just now
49-
test: on
50-
51-
artifacts:
52-
- path: artifacts\*.nupkg
53-
- path: artifacts\*.zip
54-
55-
deploy:
56-
# MyGet Deployment for builds & releases
57-
- provider: NuGet
58-
server: https://www.myget.org/F/umbraco-packages/api/v2/package
59-
symbol_server: https://www.myget.org/F/umbraco-packages/symbols/api/v2/package
60-
api_key:
61-
secure: yvlnQEq6tmxGOdbtTuKyAhcdY1GCD98/sG9+Qo7y7SNb89GAbjLXxueOMspkjvUh
62-
artifact: /.*\.nupkg/
63-
on:
64-
branch: develop
65-
66-
# Umbraco MyGet community feed
67-
- provider: NuGet
68-
server: https://www.myget.org/F/umbraco-packages/api/v2/package
69-
symbol_server: https://www.myget.org/F/umbraco-packages/symbols/api/v2/package
70-
api_key:
71-
secure: yvlnQEq6tmxGOdbtTuKyAhcdY1GCD98/sG9+Qo7y7SNb89GAbjLXxueOMspkjvUh
72-
artifact: /.*\.nupkg/
73-
on:
74-
branch: develop-umbraco-version-8
75-
76-
# GitHub Deployment for releases
77-
- provider: GitHub
78-
auth_token:
79-
secure: Kucu1gQQf8bjRlkR72fyZUiUtmkz7rtZEIgK/RMT1pMnq700m5sSQTiFHOSQUdR5
80-
artifact: /.*\.zip/ # upload all Zip packages to release assets
81-
draft: false
82-
prerelease: false
83-
on:
84-
branch: master
85-
appveyor_repo_tag: true # deploy on tag push only
86-
87-
# NuGet Deployment for releases
88-
- provider: NuGet
89-
server:
90-
api_key:
91-
secure: TtE4dizVNNLoy4gfrJDGRH1/vfNMTXiAxuMW0va1bcO1ZPXCw0qy12PUfIB+h9O3
92-
artifact: /.*\.nupkg/
93-
on:
94-
branch: master
95-
appveyor_repo_tag: true
96-
97-
# GitHub Deployment for releases
98-
- provider: GitHub
99-
auth_token:
100-
secure: Kucu1gQQf8bjRlkR72fyZUiUtmkz7rtZEIgK/RMT1pMnq700m5sSQTiFHOSQUdR5
101-
artifact: /.*\.zip/ # upload all Zip packages to release assets
102-
draft: false
103-
prerelease: false
104-
on:
105-
branch: master-umbraco-version-8
106-
appveyor_repo_tag: true # deploy on tag push only
107-
108-
# NuGet Deployment for releases
109-
- provider: NuGet
110-
server:
111-
api_key:
112-
secure: TtE4dizVNNLoy4gfrJDGRH1/vfNMTXiAxuMW0va1bcO1ZPXCw0qy12PUfIB+h9O3
113-
artifact: /.*\.nupkg/
114-
on:
115-
branch: master-umbraco-version-8
116-
appveyor_repo_tag: true
1+
version: 2.1.0.{build}
2+
3+
os: Visual Studio 2019
4+
5+
cache:
6+
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified
7+
8+
configuration: Release
9+
10+
environment:
11+
# Version Suffix
12+
version_suffix: alpha
13+
14+
install:
15+
- ps: .\build\appveyor-semver.ps1
16+
- ps: .\build\check-release-version.ps1
17+
- ps: Update-AppveyorBuild -Version $Env:appveyor_version
18+
- cmd: >-
19+
cd build
20+
21+
npm install
22+
23+
node appveyor-nuspec-patch.js
24+
25+
cd..
26+
- ps: >-
27+
$msiPath = "$($env:USERPROFILE)\MicrosoftAzureStorageEmulator.msi"
28+
29+
(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/F/3/8/F3857A38-D344-43B4-8E5B-2D03489909B9/MicrosoftAzureStorageEmulator.msi', $msiPath)
30+
31+
cmd /c start /wait msiexec /i $msiPath /quiet
32+
33+
assembly_info:
34+
patch: true
35+
file: 'src\UmbracoFileSystemProviders.Azure**\AssemblyInfo.*'
36+
assembly_version: '$(appveyor_file_version)'
37+
assembly_file_version: '$(appveyor_file_version)'
38+
assembly_informational_version: '$(mssemver)'
39+
40+
build_script:
41+
- cmd: >-
42+
build-appveyor.cmd
43+
44+
cd..
45+
46+
before_test:
47+
- cmd: '"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" start'
48+
# Turn tests off just now
49+
test: on
50+
51+
artifacts:
52+
- path: artifacts\*.nupkg
53+
- path: artifacts\*.zip
54+
55+
deploy:
56+
# MyGet Deployment for builds & releases
57+
- provider: NuGet
58+
server: https://www.myget.org/F/umbraco-packages/api/v2/package
59+
symbol_server: https://www.myget.org/F/umbraco-packages/symbols/api/v2/package
60+
api_key:
61+
secure: yvlnQEq6tmxGOdbtTuKyAhcdY1GCD98/sG9+Qo7y7SNb89GAbjLXxueOMspkjvUh
62+
artifact: /.*\.nupkg/
63+
on:
64+
branch: develop
65+
66+
# Umbraco MyGet community feed
67+
- provider: NuGet
68+
server: https://www.myget.org/F/umbraco-packages/api/v2/package
69+
symbol_server: https://www.myget.org/F/umbraco-packages/symbols/api/v2/package
70+
api_key:
71+
secure: yvlnQEq6tmxGOdbtTuKyAhcdY1GCD98/sG9+Qo7y7SNb89GAbjLXxueOMspkjvUh
72+
artifact: /.*\.nupkg/
73+
on:
74+
branch: develop-umbraco-version-8
75+
76+
# GitHub Deployment for releases
77+
- provider: GitHub
78+
auth_token:
79+
secure: Kucu1gQQf8bjRlkR72fyZUiUtmkz7rtZEIgK/RMT1pMnq700m5sSQTiFHOSQUdR5
80+
artifact: /.*\.zip/ # upload all Zip packages to release assets
81+
draft: false
82+
prerelease: false
83+
on:
84+
branch: master
85+
appveyor_repo_tag: true # deploy on tag push only
86+
87+
# NuGet Deployment for releases
88+
- provider: NuGet
89+
server:
90+
api_key:
91+
secure: TtE4dizVNNLoy4gfrJDGRH1/vfNMTXiAxuMW0va1bcO1ZPXCw0qy12PUfIB+h9O3
92+
artifact: /.*\.nupkg/
93+
on:
94+
branch: master
95+
appveyor_repo_tag: true
96+
97+
# GitHub Deployment for releases
98+
- provider: GitHub
99+
auth_token:
100+
secure: Kucu1gQQf8bjRlkR72fyZUiUtmkz7rtZEIgK/RMT1pMnq700m5sSQTiFHOSQUdR5
101+
artifact: /.*\.zip/ # upload all Zip packages to release assets
102+
draft: false
103+
prerelease: false
104+
on:
105+
branch: master-umbraco-version-8
106+
appveyor_repo_tag: true # deploy on tag push only
107+
108+
# NuGet Deployment for releases
109+
- provider: NuGet
110+
server:
111+
api_key:
112+
secure: TtE4dizVNNLoy4gfrJDGRH1/vfNMTXiAxuMW0va1bcO1ZPXCw0qy12PUfIB+h9O3
113+
artifact: /.*\.nupkg/
114+
on:
115+
branch: master-umbraco-version-8
116+
appveyor_repo_tag: true

build/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"jsonfile": "^2.2.3",
99
"semver": "^5.0.3",
10-
"xmldom": "^0.1.27",
10+
"xmldom": "^0.5.0",
1111
"read-file": "^0.2.0",
1212
"write": "^0.3.2",
1313
"js-yaml": "^3.7.0"

src/UmbracoFileSystemProviders.Azure.Installer/InstallerController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ private static bool ExecuteImageProcessorSecurityConfigTransform()
446446

447447
private static bool TestAzureCredentials(string connectionString, string containerName, PublicAccessType accessType)
448448
{
449-
bool useEmulator = ConfigurationManager.AppSettings[Azure.Constants.Configuration.UseStorageEmulatorKey] != null
450-
&& ConfigurationManager.AppSettings[Azure.Constants.Configuration.UseStorageEmulatorKey]
449+
bool useEmulator = ConfigurationHelper.GetAppSetting(Azure.Constants.Configuration.UseStorageEmulatorKey) != null
450+
&& ConfigurationHelper.GetAppSetting(Azure.Constants.Configuration.UseStorageEmulatorKey)
451451
.Equals("true", StringComparison.InvariantCultureIgnoreCase);
452452
try
453453
{

src/UmbracoFileSystemProviders.Azure.Media/AzureMediaFileSystemComponent.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
// </copyright>
55
namespace Our.Umbraco.FileSystemProviders.Azure
66
{
7+
using System;
78
using global:: Umbraco.Core.Composing;
89
using global::Umbraco.Core.IO;
910

1011
public class AzureMediaFileSystemComponent : IComponent
1112
{
12-
1313
private readonly SupportingFileSystems supportingFileSystems;
1414
private readonly AzureBlobFileSystemConfig config;
1515

@@ -22,19 +22,14 @@ public AzureMediaFileSystemComponent(SupportingFileSystems supportingFileSystems
2222
public void Initialize()
2323
{
2424
var azureFs = this.supportingFileSystems.For<IMediaFileSystem>() as AzureBlobFileSystem;
25+
2526
if (!this.config.DisableVirtualPathProvider && azureFs != null)
2627
{
2728
AzureFileSystem azureFileSystem = azureFs.FileSystem;
2829

29-
// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
30-
if (azureFileSystem.UseDefaultRoute)
31-
{
32-
FileSystemVirtualPathProvider.ConfigureMedia(Constants.DefaultMediaRoute);
33-
}
34-
else
35-
{
36-
FileSystemVirtualPathProvider.ConfigureMedia(azureFileSystem.ContainerName);
37-
}
30+
var route = azureFileSystem.UseDefaultRoute ? Constants.DefaultMediaRoute : azureFileSystem.ContainerName;
31+
32+
FileSystemVirtualPathProvider.Configure(route, new Lazy<IFileSystem>(() => azureFileSystem));
3833
}
3934
}
4035

src/UmbracoFileSystemProviders.Azure/AzureBlobFileSystem.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,34 +113,34 @@ public AzureBlobFileSystem(string containerName, string rootUrl, string connecti
113113
/// <param name="alias">The alias of the provider</param>
114114
public AzureBlobFileSystem(string alias)
115115
{
116-
string connectionString = ConfigurationManager.AppSettings[$"{ConnectionStringKey}:{alias}"];
116+
string connectionString = ConfigurationHelper.GetAppSetting(ConnectionStringKey,alias);
117117
if (!string.IsNullOrWhiteSpace(connectionString))
118118
{
119-
string rootUrl = ConfigurationManager.AppSettings[$"{RootUrlKey}:{alias}"];
119+
string rootUrl = ConfigurationHelper.GetAppSetting(RootUrlKey,alias);
120120
if (string.IsNullOrWhiteSpace(rootUrl))
121121
{
122122
throw new InvalidOperationException("Azure Storage Root URL is not defined in application settings. The " + RootUrlKey + " property was not defined or is empty.");
123123
}
124124

125-
string containerName = ConfigurationManager.AppSettings[$"{ContainerNameKey}:{alias}"];
125+
string containerName = ConfigurationHelper.GetAppSetting(ContainerNameKey,alias);
126126
if (string.IsNullOrWhiteSpace(containerName))
127127
{
128128
containerName = "media";
129129
}
130130

131-
string maxDays = ConfigurationManager.AppSettings[$"{MaxDaysKey}:{alias}"];
131+
string maxDays = ConfigurationHelper.GetAppSetting(MaxDaysKey,alias);
132132
if (string.IsNullOrWhiteSpace(maxDays))
133133
{
134134
maxDays = "365";
135135
}
136136

137-
string useDefaultRoute = ConfigurationManager.AppSettings[$"{UseDefaultRootKey}:{alias}"];
137+
string useDefaultRoute = ConfigurationHelper.GetAppSetting(UseDefaultRootKey,alias);
138138
if (string.IsNullOrWhiteSpace(useDefaultRoute))
139139
{
140140
useDefaultRoute = "true";
141141
}
142142

143-
string accessType = ConfigurationManager.AppSettings[$"{UsePrivateContainerKey}:{alias}"];
143+
string accessType = ConfigurationHelper.GetAppSetting(UsePrivateContainerKey,alias);
144144
if (string.IsNullOrWhiteSpace(accessType))
145145
{
146146
accessType = "true";

src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ internal AzureFileSystem(string containerName, string rootUrl, string connection
9696
throw new ArgumentNullException(nameof(containerName));
9797
}
9898

99-
this.DisableVirtualPathProvider = ConfigurationManager.AppSettings[DisableVirtualPathProviderKey] != null
100-
&& ConfigurationManager.AppSettings[DisableVirtualPathProviderKey]
99+
this.DisableVirtualPathProvider = ConfigurationHelper.GetAppSetting(DisableVirtualPathProviderKey) != null
100+
&& ConfigurationHelper.GetAppSetting(DisableVirtualPathProviderKey)
101101
.Equals("true", StringComparison.InvariantCultureIgnoreCase);
102102

103-
bool useEmulator = ConfigurationManager.AppSettings[UseStorageEmulatorKey] != null
104-
&& ConfigurationManager.AppSettings[UseStorageEmulatorKey]
103+
bool useEmulator = ConfigurationHelper.GetAppSetting(UseStorageEmulatorKey) != null
104+
&& ConfigurationHelper.GetAppSetting(UseStorageEmulatorKey)
105105
.Equals("true", StringComparison.InvariantCultureIgnoreCase);
106106

107107
if (useEmulator)

0 commit comments

Comments
 (0)