- 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.
推薦閱讀
- Linux運維之道(第3版)
- Linux網絡管理與配置(第2版)
- Windows Server 2012 Hyper-V:Deploying the Hyper-V Enterprise Server Virtualization Platform
- Kali Linux滲透測試全流程詳解
- 嵌入式應用程序設計綜合教程(微課版)
- 構建可擴展分布式系統:方法與實踐
- Alfresco 4 Enterprise Content Management Implementation
- 嵌入式系統原理及開發
- Mobile First Design with HTML5 and CSS3
- Android物聯網開發細致入門與最佳實踐
- Hands-On UX Design for Developers
- Windows 7實戰從入門到精通(超值版)
- Implementing Domain-Specific Languages with Xtext and Xtend(Second Edition)
- Implementing Cloud Design Patterns for AWS(Second Edition)
- Mastering Eclipse Plug-in Development