Azure缓存编程配置导致ErrorCode ERRCA0029 SubStatus ES0001用户传递的授权令牌无效

时间:2012-09-11 19:02:34

标签: c# .net azure azure-caching azure-sdk-.net

我正在尝试基于http://msdn.microsoft.com/en-us/library/windowsazure/gg618003的代码的概念证明。如果我使用app.config设置,则可以访问此缓存。当我将应用程序切换为使用程序配置时,我始终遇到此错误。我已经尝试了Azure cache programatically configuration fail to verify和许多其他解决方案无济于事。

这是我的代码段。

{代码}

        String                              acsKey = "AcsKey removed intentionaly";
        DataCacheFactoryConfiguration       cacheFactoryConfiguration;
        DataCacheSecurity                   dataCacheSecurity;
        DataCacheServerEndpoint[]           serverEndpoints = new DataCacheServerEndpoint[1];
        SecureString                        secureAcsKey = new SecureString();

        serverEndpoints[0] = new DataCacheServerEndpoint("EndPont removed intentionaly", 22243);

        //
        // Create SecureString from string
        //
        foreach (char keyChar in acsKey)
        {
           secureAcsKey.AppendChar(keyChar);
        }
        secureAcsKey.MakeReadOnly();
        dataCacheSecurity  = new DataCacheSecurity(secureAcsKey);

        //
        // Initialize Factory Configuration
        //

        cacheFactoryConfiguration = new DataCacheFactoryConfiguration(); // This line throws exception. Note that the key is yet to be assigned to SecurityProperties as per documentation.
        cacheFactoryConfiguration.Servers = serverEndpoints;
        cacheFactoryConfiguration.SecurityProperties = dataCacheSecurity;

        _cacheFactory = new DataCacheFactory(cacheFactoryConfiguration);
        _cache = _cacheFactory.GetDefaultCache();

{代码}

1 个答案:

答案 0 :(得分:0)

尝试在创建时传递所有参数,而不是在创建后传递?

    var configFactory = new DataCacheFactoryConfiguration
                            {
                                Servers =
                                    new List<DataCacheServerEndpoint>
                                        {new DataCacheServerEndpoint(cacheServer, cachePort)},
                                SecurityProperties =
                                    new DataCacheSecurity(Encryption.CreateSecureString(cacheAuthorization),
                                                          true)
                            };
相关问题