- Microsoft Azure Administrator:Exam Guide AZ-103
- Sjoukje Zaal
- 251字
- 2021-06-24 14:02:01
Creating a custom role
In the following example, we will create a custom role that can only restart VMs in Azure. For this, you need to create a JSON file that will be deployed using PowerShell. We are assigning that role to a user account inside the JSON file, as follows:
- You can define the custom role by using the following JSON code. You should set the Id to null because the custom role gets an ID assigned to it at creation. We will add the custom role to two Azure subscriptions, as follows (replace the subscriptions in the AssignableScopes part with your subscription IDs):
{
"Name": "Packt Custom Role",
"Id": null,
"IsCustom": true,
"Description": "Allows for read access to Azure Storage, Network and Compute resources and access to support",
"Actions": [
"Microsoft.Compute/*/read",
"Microsoft.Storage/*/read",
"Microsoft.Network/*/read",
"Microsoft.Resources/subscriptions/resourceGroups/read",
"Microsoft.Support/*"
],
"NotActions": [
],
"AssignableScopes": [
"/subscriptions/********-****-****-****-***********",
"/subscriptions/********-****-****-****-***********"
]
}
- Save the JSON file in a folder named CustomRoles on the C: drive of your computer. Then, run the following PowerShell script to create the role. First, log in to your Azure account, as follows:
Connect-AzAccount
- If necessary, select the right subscription:
Select-AzSubscription -SubscriptionId "********-****-****-****-***********"
- Then, create the custom role in Azure by importing the JSON file into PowerShell:
New-AzRoleDefinition -InputFile "C:\CustomRoles\PacktCustomRole.json"
In this demonstration, we created a custom role that can only restart VMs in Azure. Now, we're going to take a look at how you can create policies using Azure Policy.
推薦閱讀
- 大學計算機應用基礎實踐教程(Windows 7+Office 2013)
- UNIX操作系統設計
- Linux操作系統應用編程
- 嵌入式操作系統(Linux篇)(微課版)
- Windows Server 2019 Administration Fundamentals
- 移動應用UI設計模式(第2版)
- Android物聯網開發細致入門與最佳實踐
- 無蘋果不生活 The New iPad隨身寶典
- Mastering Reactive JavaScript
- 寫給架構師的Linux實踐:設計并實現基于Linux的IT解決方案
- Windows 10從新手到高手
- 從實踐中學習Windows滲透測試
- μC/OS-III內核實現與應用開發實戰指南:基于STM32
- Agile IT Security Implementation Methodology
- Office 365 User Guide