无法删除自定义角色定义-现有角色分配

时间:2020-07-30 13:20:43

标签: azure azure-rbac

我有一个自定义角色,据我所知没有任何作业。但是我无法删除它。 检查下面的屏幕截图。

错误显示class MainOrientation : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val names = listOf( "Surface.ROTATION_0", "Surface.ROTATION_90", "Surface.ROTATION_180", "Surface.ROTATION_270" ) listOf( // test all possible device rotation Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, Surface.ROTATION_270 ).forEachIndexed { idx, displayRotation -> // get related orientation (between device orientation and its camera sensor) // for example for MediaRecorder.setOrientationHint(int) Log.d(TAG, "Display Surface Rotation is ${names[idx]}") Log.d(TAG, " ") // two different methods for camera2 API (based on Google GitHub samples) computeRelativeRotationCamera2New(this, displayRotation) // from current camera2 samples https://github.com/android/camera-samples computeRelativeRotationCamera2(this, displayRotation) // from archived camera2 sample https://github.com/googlearchive/android-Camera2Basic // deprecated camera API (based on Android Camera API documentation) computeRelativeRotationCameraDeprecated(displayRotation) // https://developer.android.com/reference/android/hardware/Camera.html Log.d(TAG, "-------------------------") /* results from logcat: Display Surface Rotation is Surface.ROTATION_0 computeRelativeRotationCamera2New 90 computeRelativeRotationCamera2 90 computeRelativeRotationCameraDeprecated 90 ------------------------- Display Surface Rotation is Surface.ROTATION_90 computeRelativeRotationCamera2New 180 computeRelativeRotationCamera2 0 computeRelativeRotationCameraDeprecated 0 ------------------------- Display Surface Rotation is Surface.ROTATION_180 computeRelativeRotationCamera2New 270 computeRelativeRotationCamera2 270 computeRelativeRotationCameraDeprecated 270 ------------------------- Display Surface Rotation is Surface.ROTATION_270 computeRelativeRotationCamera2New 0 computeRelativeRotationCamera2 180 computeRelativeRotationCameraDeprecated 180 */ } } /** * Computes rotation required to transform from the camera sensor orientation to the * device's current orientation in degrees. * * @param characteristics the [CameraCharacteristics] to query for the sensor orientation. * @param surfaceRotation the current device orientation as a Surface constant * @return the relative rotation from the camera sensor to the current device orientation. */ // https://github.com/android/camera-samples/blob/master/CameraUtils/lib/src/main/java/com/example/android/camera/utils/OrientationLiveData.kt#L71 // https://github.com/android/camera-samples/blob/master/Camera2Video/app/src/main/java/com/example/android/camera2/video/fragments/CameraFragment.kt#L273 private fun computeRelativeRotationCamera2New( context: Context, surfaceRotation: Int ): Int { val characteristics = getCameraCharacteristics(context) val sensorOrientationDegrees = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION)!! val deviceOrientationDegrees = when (surfaceRotation) { Surface.ROTATION_0 -> 0 Surface.ROTATION_90 -> 90 Surface.ROTATION_180 -> 180 Surface.ROTATION_270 -> 270 else -> 0 } // Reverse device orientation for front-facing cameras val sign = if (characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT ) 1 else -1 // Calculate desired JPEG orientation relative to camera orientation to make // the image upright relative to the device orientation val result = (sensorOrientationDegrees - (deviceOrientationDegrees * sign) + 360) % 360 Log.d(TAG, "computeRelativeRotationCamera2New $result") return result } // https://github.com/googlearchive/android-Camera2Video/blob/master/kotlinApp/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.kt#L479 private fun computeRelativeRotationCamera2(context: Context, surfaceRotation: Int) { // for computeRelativeRotationCamera2() val SENSOR_ORIENTATION_DEFAULT_DEGREES = 90 val SENSOR_ORIENTATION_INVERSE_DEGREES = 270 val DEFAULT_ORIENTATIONS = SparseIntArray().apply { append(Surface.ROTATION_0, 90) append(Surface.ROTATION_90, 0) append(Surface.ROTATION_180, 270) append(Surface.ROTATION_270, 180) } val INVERSE_ORIENTATIONS = SparseIntArray().apply { append(Surface.ROTATION_0, 270) append(Surface.ROTATION_90, 180) append(Surface.ROTATION_180, 90) append(Surface.ROTATION_270, 0) } when (getCameraCharacteristics(context).get(CameraCharacteristics.SENSOR_ORIENTATION)!!) { SENSOR_ORIENTATION_DEFAULT_DEGREES -> Log.d( TAG, "computeRelativeRotationCamera2 ${DEFAULT_ORIENTATIONS.get(surfaceRotation)}" ) SENSOR_ORIENTATION_INVERSE_DEGREES -> Log.d( TAG, "computeRelativeRotationCamera2 ${INVERSE_ORIENTATIONS.get(surfaceRotation)}" ) } } // https://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation%28int%29 private fun computeRelativeRotationCameraDeprecated( surfaceRotation: Int ): Int { val cameraInfo = getCameraDeprecatedInfo() val degrees = when (surfaceRotation) { Surface.ROTATION_0 -> 0 Surface.ROTATION_90 -> 90 Surface.ROTATION_180 -> 180 Surface.ROTATION_270 -> 270 else -> 0 } var result: Int if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (cameraInfo.orientation + degrees) % 360 result = (360 - result) % 360 // compensate the mirror } else { // back-facing result = (cameraInfo.orientation - degrees + 360) % 360 } Log.d(TAG, "computeRelativeRotationCameraDeprecated $result") return result } companion object { // methods to get info about camera using deprecated camera and camera2 APIs private fun getCameraManager(context: Context) = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager private fun getCameraId(manager: CameraManager): String { return manager.cameraIdList.first { val characteristics = manager.getCameraCharacteristics(it) val facing = characteristics.get(CameraCharacteristics.LENS_FACING) facing == CameraCharacteristics.LENS_FACING_BACK } } private fun getCameraCharacteristics(context: Context): CameraCharacteristics { val manager = getCameraManager(context) return manager.getCameraCharacteristics(getCameraId(manager)) } private fun getCameraDeprecatedInfo(): Camera.CameraInfo { val cameraInfo = Camera.CameraInfo() Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, cameraInfo) return cameraInfo } private const val TAG = "orientation" } }

enter image description here

这是订阅级别的IAM控件。它显示底部有0个分配。

有人知道为什么我不能删除它吗? 有没有办法查看该角色是否确实有受让人?

欢迎任何帮助。

1 个答案:

答案 0 :(得分:0)

我将尝试运行Get-AzRoleAssignment Powershell命令以返回所有分配。可能已经分配了一个ID或资源,而该ID或资源已被删除而成为孤立的。

要完成第一次运行:

connect-azaccount

这将提示您登录Azure。完成后,然后切换到您要由Select-AzureSubscription运行的订阅,例如:

Select-AzureSubscription -SubscriptionName <SUBSCRIPTION NAME>

然后像下面这样运行Get-AzRoleAssignment:

Get-AzRoleAssignment -RoleDefinition ROLENAME

如果这返回一个列表,则对返回的每个对象ID运行Remove-AzRoleAssignment

Remove-AzureRmRoleAssignment-ObjectId <Guid>