예제 #1
0
 protected static void InitializeTokenCaches()
 {
     DefaultMemoryTokenCache = TokenCache.DefaultShared;
     if (!string.IsNullOrWhiteSpace(AzureSession.ProfileDirectory) &&
         !string.IsNullOrWhiteSpace(AzureSession.TokenCacheFile))
     {
         GeneralUtilities.EnsureDefaultProfileDirectoryExists();
         DefaultDiskTokenCache = new ProtectedFileTokenCache(Path.Combine(AzureSession.ProfileDirectory, AzureSession.TokenCacheFile));
     }
     else
     {
         DefaultDiskTokenCache = DefaultMemoryTokenCache;
     }
 }
예제 #2
0
        /// <summary>
        /// Create the default profile, based on the default profile path
        /// </summary>
        /// <returns>The default profile, serialized from the default location on disk</returns>
        protected static AzureProfile InitializeDefaultProfile()
        {
            if (!string.IsNullOrEmpty(AzureSession.ProfileDirectory) && !string.IsNullOrEmpty(AzureSession.ProfileFile))
            {
                try
                {
                    GeneralUtilities.EnsureDefaultProfileDirectoryExists();
                    return(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
                }
                catch
                {
                    // swallow exceptions in creating the profile from disk
                }
            }

            return(new AzureProfile());
        }