Last active
August 29, 2015 14:01
-
-
Save nnasaki/4766bb22cd76c5e66754 to your computer and use it in GitHub Desktop.
Microsoft.WindowsAzure.Management Library を Azure Web Siteで動かそうとしたら、動きませんでした。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
エラーメッセージ | |
System.Security.Cryptography.CryptographicException はユーザー コードによってハンドルされませんでした。 | |
HResult=-2147024894 | |
Message=The system cannot find the file specified. | |
Source=mscorlib | |
StackTrace: | |
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) | |
at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) | |
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags) | |
at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] data) | |
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData) | |
at managementforwebsite.Controllers.HomeController.About() in c:\Users\nnasaki\Documents\Visual Studio 2013\Projects\azuremanagement\managementforwebsite\Controllers\HomeController.cs:line 25 | |
at lambda_method(Closure , ControllerBase , Object[] ) | |
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) | |
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) | |
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) | |
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__36(IAsyncResult asyncResult, ActionInvocation innerInvokeState) | |
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) | |
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() | |
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) | |
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3c() | |
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() | |
InnerException: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
動かそうとしたサンプルコードはこれ。 | |
`var credentials = new CertificateCloudCredentials` でExceptionが発生します。 | |
using Microsoft.WindowsAzure; | |
using Microsoft.WindowsAzure.Management.WebSites; | |
using Microsoft.WindowsAzure.Management.WebSites.Models; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Security.Cryptography.X509Certificates; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace azuremanagement | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var subscriptionId = "xxxxx"; | |
var base64Certificate = "xxxx"; | |
var credentials = new CertificateCloudCredentials(subscriptionId, new X509Certificate2(Convert.FromBase64String(base64Certificate))); | |
using (var client = new WebSiteManagementClient(credentials)) | |
{ | |
var spaces = client.WebSpaces.List(); | |
foreach (var space in spaces) | |
{ | |
Console.WriteLine("Space: {0}", space.Name); | |
var sites = client.WebSpaces.ListWebSites(space.Name, new WebSiteListParameters { PropertiesToInclude = { "Name" } }); | |
foreach (var site in sites) | |
{ | |
Console.WriteLine(" " + site.Name); | |
} | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/9951729/x509certificate-constructor-exception に | |
> Turns out there's a setting in the IIS Application Pool configuration (Application Pools > Advanced Settings) to load the user profile for the application pool identity user. When set to false, the key containers aren't accessible. | |
とあるので、アプリケーションプールの設定を変える必要があるのでWebSiteじゃ無理? | |
SiteExtensionsでなんとかなるんでしょうか? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment