Пример #1
0
        public DiagnosticsResult GetXDeviceResult()
        {
            DiagnosticsResult result = new DiagnosticsResult
            {
                Type = XInputDiagnosticsTypes.XDevice,
            };

            if (GetVigemDeviceResult().State != DiagnosticsResultState.Passed)
            {
                if (GetScpDeviceResult().State != DiagnosticsResultState.Passed)
                {
                    result.Value = false;
                    result.State = DiagnosticsResultState.Failed;
                }
                else
                {
                    result.Value = true;
                    result.State = DiagnosticsResultState.Warning;
                }
            }
            else
            {
                result.Value = true;
                result.State = DiagnosticsResultState.Passed;
            }
            return(result);
        }
        private TypedPair <ArmResource <ArmFunctionApp> > CheckValidFunctionAppResource(ArmResource <ArmFunctionApp> functionApp)
        {
            DiagnosticsResult result;

            if (!functionApp.Properties.Enabled ||
                !functionApp.Properties.AdminEnabled ||
                functionApp.Properties.SiteDisabledReason != 0 ||
                functionApp.Properties.SuspendedTill != null)
            {
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true,
                    Code          = GetSupportErrorCode(ActionIds.FunctionAppIsStopped, functionApp),
                    SuccessResult = new DiagnoseSuccessResult
                    {
                        IsTerminating = true,
                        Message       = "Your function app is disabled. It can be disabled because it ran out of quota or if your subscription is disabled.",
                        UserAction    = "Understand why your application is suspended and try again after it is no longer suspended.",
                        ActionId      = ActionIds.FunctionAppIsStopped
                    }
                };
            }
            else if (functionApp.Properties.HostNameSslStates == null ||
                     functionApp.Properties.HostNameSslStates.Count() < 2 ||
                     !functionApp.Properties.HostNameSslStates.Any(h => h.HostType == 1) ||
                     !functionApp.Properties.HostNameSslStates.Any(h => h.HostType == 0) ||
                     string.IsNullOrEmpty(functionApp.Properties.DefaultHostName))
            {
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true,
                    Code          = GetSupportErrorCode(ActionIds.AppIsMisconfiguredInAzure, functionApp),
                    SuccessResult = new DiagnoseSuccessResult
                    {
                        IsTerminating = true,
                        Message       = "Your function app appears to not have been created successfully.",
                        UserAction    = "You can either try deleting and re-creating the function app or contact support.",
                        ActionId      = ActionIds.AppIsMisconfiguredInAzure
                    }
                };
            }
            else
            {
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true
                };
            }

            return(new TypedPair <ArmResource <ArmFunctionApp> >(result, functionApp));
        }
Пример #3
0
        public DiagnosticsResult GetDPadResult()
        {
            int dPadsCount           = device.DPads.Count();
            DiagnosticsResult result = new DiagnosticsResult
            {
                Value = dPadsCount,
                Type  = InputDiagnosticsTypes.DPadCount,
            };

            if (dPadsCount < 1)
            {
                result.State = DiagnosticsResultState.Warning;
            }
            else
            {
                result.State = DiagnosticsResultState.Passed;
            }
            return(result);
        }
Пример #4
0
        public DiagnosticsResult GetButtonsResult()
        {
            int buttonsCount         = device.Sources.Where(s => s.Type == InputSourceTypes.Button).Count();
            DiagnosticsResult result = new DiagnosticsResult
            {
                Value = buttonsCount,
                Type  = InputDiagnosticsTypes.ButtonsCount,
            };

            if (buttonsCount < 8)
            {
                result.State = DiagnosticsResultState.Warning;
            }
            else
            {
                result.State = DiagnosticsResultState.Passed;
            }
            return(result);
        }
Пример #5
0
        public DiagnosticsResult GetAxesResult()
        {
            int axesCount            = device.Sources.Where(s => s.Type == InputSourceTypes.Axis).Count();
            DiagnosticsResult result = new DiagnosticsResult
            {
                Value = axesCount,
                Type  = InputDiagnosticsTypes.AxesCount,
            };

            if (axesCount < 4)
            {
                result.State = DiagnosticsResultState.Warning;
            }
            else
            {
                result.State = DiagnosticsResultState.Passed;
            }
            return(result);
        }
Пример #6
0
        public DiagnosticsResult GetForceFeedbackResult()
        {
            int forceFeedbackCount   = device.ForceFeedbackCount;
            DiagnosticsResult result = new DiagnosticsResult
            {
                Value = forceFeedbackCount,
                Type  = InputDiagnosticsTypes.ForceFeedbackCount,
            };

            if (forceFeedbackCount < 1)
            {
                result.State = DiagnosticsResultState.Warning;
            }
            else
            {
                result.State = DiagnosticsResultState.Passed;
            }
            return(result);
        }
Пример #7
0
        public DiagnosticsResult GetVigemDeviceResult()
        {
            DiagnosticsResult result = new DiagnosticsResult
            {
                Type = XInputDiagnosticsTypes.VigemDevice,
            };

            if (VigemDevice.IsAvailable())
            {
                result.Value = true;
                result.State = DiagnosticsResultState.Passed;
            }
            else
            {
                result.Value = false;
                result.State = DiagnosticsResultState.Warning;
            }
            return(result);
        }
 public TypedPair(DiagnosticsResult result, T data)
 {
     Data = data;
     DiagnosticsResults = new[] { result };
 }
        /// <summary>
        /// The master key is created by Kudu or the runtime; however it seems to be very common for people
        /// to get in a state where the encryption keys can't decrypt that key, and the apps are in
        /// a completely broken state until this is corrected.
        /// <param name="functionApp"> the function app object to check the master key for </param>
        /// </summary>
        private async Task <TypedPair <string> > CheckMasterKey(ArmResource <ArmFunctionApp> functionApp)
        {
            // Get kudu's url from the function app.
            // Though this might throw due to various oddities that happen in Antares every now and then,
            // the check for the existence of correct numbers of hostNames is taken care of in the CheckResource()
            // method, which should be called before this one.
            var scmUrl          = functionApp.Properties.HostNameSslStates.First(h => h.HostType == 1).Name;
            var masterKeyResult = await _client.Get <MasterKey>(new Uri($"https://{scmUrl}/api/functions/admin/masterkey"));

            DiagnosticsResult result;

            if (masterKeyResult.IsSuccessful)
            {
                // Nothing to do here. The look up was successful, so return a successful diagnose with no user action
                // and also return the master key.
                return(new TypedPair <string>(new DiagnosticsResult {
                    IsDiagnosingSuccessful = true
                }, masterKeyResult.Result.Key));
            }
            else if (masterKeyResult.Error.StatusCode == HttpStatusCode.InternalServerError)
            {
                try
                {
                    // This is most probably the crypto issue.
                    // However to be sure, check the content for a WebApiException that says so.
                    var content = await masterKeyResult.Error.Content.ReadAsAsync <WebApiException>();

                    if (!string.IsNullOrEmpty(content.ExceptionType) &&
                        content.ExceptionType.Equals("System.Security.Cryptography.CryptographicException", StringComparison.OrdinalIgnoreCase))
                    {
                        // Yep it's the crypto error, build the correct DiagnosticsResult object
                        result = new DiagnosticsResult
                        {
                            IsDiagnosingSuccessful = true,
                            Code          = GetSupportErrorCode(ActionIds.KeysUnexpectedError, content, masterKeyResult.Error, functionApp),
                            SuccessResult = new DiagnoseSuccessResult
                            {
                                // This is a terminating error. This is almost exactly why this user is seeing errors in the portal.
                                IsTerminating = true,
                                Message       = "We are unable to decrypt your function access keys. This can happen if you delete and recreate the app with the same name, or if you copied your keys from a different function app.",
                                UserAction    = "Follow steps here https://go.microsoft.com/fwlink/?linkid=844094",
                                ActionId      = ActionIds.KeysUnexpectedError
                            }
                        };
                    }
                    else
                    {
                        result = new DiagnosticsResult
                        {
                            IsDiagnosingSuccessful = true,
                            Code          = GetSupportErrorCode(ActionIds.KeysUnexpectedError, masterKeyResult.Error, functionApp),
                            SuccessResult = new DiagnoseSuccessResult
                            {
                                // Even though we don't know what's going on, we still mark it as terminating because we can't get
                                // the masterkey still.
                                IsTerminating = true,
                                Message       = "We are unable to access your function keys.",
                                UserAction    = "If the error persists, please contact support.",
                                ActionId      = ActionIds.KeysUnexpectedError
                            }
                        };
                    }
                }
                catch
                {
                    // Though it's a 500, it's not the crypto error. I don't know of any other reason this API might return 500
                    // but handle that nonetheless.
                    result = new DiagnosticsResult
                    {
                        IsDiagnosingSuccessful = true,
                        Code          = GetSupportErrorCode(ActionIds.KeysUnexpectedError, masterKeyResult.Error, functionApp),
                        SuccessResult = new DiagnoseSuccessResult
                        {
                            // Even though we don't know what's going on, we still mark it as terminating because we can't get
                            // the masterkey still.
                            IsTerminating = true,
                            Message       = "We are unable to access your function keys.",
                            UserAction    = "If the error persists, please contact support.",
                            ActionId      = ActionIds.KeysUnexpectedError
                        }
                    };
                }
            }
            else
            {
                // It didn't fail with 500, but nonetheless it failed for some other reason.
                // At the moment I'm not aware of any other reason, but handle it anyway.
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true,
                    Code          = GetSupportErrorCode(ActionIds.KeysUnexpectedError, masterKeyResult.Error, functionApp),
                    SuccessResult = new DiagnoseSuccessResult
                    {
                        // Ditto. Can't get the masterKey, so it has to be terminating.
                        IsTerminating = true,
                        Message       = "We are unable to access your function keys.",
                        UserAction    = "If the error persists, please contact support.",
                        ActionId      = ActionIds.KeysUnexpectedError
                    }
                };
            }

            return(new TypedPair <string>(result, null));
        }
Пример #10
0
        private TypedPair <ArmResource <ArmFunctionApp> > CheckValidFunctionAppResource(ArmResource <ArmFunctionApp> functionApp)
        {
            DiagnosticsResult result;

            if (!functionApp.Properties.Enabled ||
                !functionApp.Properties.AdminEnabled ||
                functionApp.Properties.SiteDisabledReason != 0 ||
                functionApp.Properties.SuspendedTill != null)
            {
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true,
                    Code          = GetSupportErrorCode(ActionIds.FunctionAppIsStopped, functionApp),
                    SuccessResult = new DiagnoseSuccessResult
                    {
                        IsTerminating = true,
                        Message       = "Your function app is disabled. It can be disabled because it ran out of quota or if your subscription is disabled.",
                        UserAction    = "Understand why your application is suspended and try again after it is no longer suspended.",
                        ActionId      = ActionIds.FunctionAppIsStopped
                    }
                };
            }
            else if (functionApp.Properties.State?.Equals("Running", StringComparison.OrdinalIgnoreCase) == false)
            {
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true,
                    Code          = GetSupportErrorCode(ActionIds.FunctionAppIsStopped, functionApp),
                    SuccessResult = new DiagnoseSuccessResult
                    {
                        IsTerminating = true,
                        Message       = "Your function app stopped.",
                        UserAction    = "You have to start your function app for the portal UX to work properly.",
                        ActionId      = ActionIds.FunctionAppIsStopped
                    }
                };
            }
            else if (functionApp.Properties.ClientCertEnabled)
            {
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true,
                    Code          = GetSupportErrorCode(ActionIds.AppIsMisconfiguredInAzure, functionApp),
                    SuccessResult = new DiagnoseSuccessResult
                    {
                        Message    = "Your function app has client certificate authentication enabled. This causes the UI to not work for function runtime scenarios (running, checking for runtime errors, access keys, etc).",
                        UserAction = "You should still be able to manage your functions. If you want the runtime to work, consider disabling client certificate on the app.",
                        ActionId   = ActionIds.AppIsMisconfiguredInAzure
                    }
                };
            }
            else if (functionApp.Properties.HostNameSslStates == null ||
                     functionApp.Properties.HostNameSslStates.Count() < 2 ||
                     !functionApp.Properties.HostNameSslStates.Any(h => h.HostType == 1) ||
                     !functionApp.Properties.HostNameSslStates.Any(h => h.HostType == 0) ||
                     string.IsNullOrEmpty(functionApp.Properties.DefaultHostName))
            {
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true,
                    Code          = GetSupportErrorCode(ActionIds.AppIsMisconfiguredInAzure, functionApp),
                    SuccessResult = new DiagnoseSuccessResult
                    {
                        IsTerminating = true,
                        Message       = "Your function app appears to not have been created successfully.",
                        UserAction    = "You can either try deleting and re-creating the function app or contact support.",
                        ActionId      = ActionIds.AppIsMisconfiguredInAzure
                    }
                };
            }
            else
            {
                result = new DiagnosticsResult
                {
                    IsDiagnosingSuccessful = true
                };
            }

            return(new TypedPair <ArmResource <ArmFunctionApp> >(result, functionApp));
        }