<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rollen &#8211; Haikos Blog</title>
	<atom:link href="https://www.hertes.net/tag/rollen/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.hertes.net</link>
	<description>Blog von Haiko Hertes zu allen Themen rund um Microsoft, Cloud und Datacenter</description>
	<lastBuildDate>Tue, 30 Mar 2021 03:22:27 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Azure &#8211; RBAC Custom Role für das starten und stoppen von VMs</title>
		<link>https://www.hertes.net/2020/02/azure-rbac-custom-role-fuer-das-starten-und-stoppen-von-vms/</link>
					<comments>https://www.hertes.net/2020/02/azure-rbac-custom-role-fuer-das-starten-und-stoppen-von-vms/#comments</comments>
		
		<dc:creator><![CDATA[Haiko]]></dc:creator>
		<pubDate>Tue, 18 Feb 2020 18:21:15 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Az]]></category>
		<category><![CDATA[Berechtigungen]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[RBAC]]></category>
		<category><![CDATA[Rechte]]></category>
		<category><![CDATA[Role]]></category>
		<category><![CDATA[Rolle]]></category>
		<category><![CDATA[Rollen]]></category>
		<category><![CDATA[Virtual Machine]]></category>
		<category><![CDATA[Virtuelle Maschine]]></category>
		<category><![CDATA[VM]]></category>
		<guid isPermaLink="false">https://www.hertes.net/?p=3893</guid>

					<description><![CDATA[Weil es die Tage bei einem meiner Kunden wieder mal ein Thema war, möchte ich es hier nun mal im Detail beleuchten. Und zwar geht es um die Anforderung, Virtuelle Maschinen in Azure starten und stoppen zu können, ohne beispielsweise die VM löschen zu können oder ihre SKU zu verändern. Natürlich gibt es den &#8222;Virtual Machine Contributor&#8220; als built-in Role, aber diese darf eben deutlich zu viel. Wie geht man nun an das Thema heran? Zunächst muss man zwei Dinge in Erfahrung bringen: Den Namen des Resource-Providers um den es geht Die Operationen auf diesem Provider, die man erlauben oder&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Weil es die Tage bei einem meiner Kunden wieder mal ein Thema war, möchte ich es hier nun mal im Detail beleuchten. Und zwar geht es um die Anforderung, Virtuelle Maschinen in Azure starten und stoppen zu können, ohne beispielsweise die VM löschen zu können oder ihre SKU zu verändern. Natürlich gibt es den &#8222;Virtual Machine Contributor&#8220; als built-in Role, aber diese darf eben deutlich zu viel.</p>



<p>Wie geht man nun an das Thema heran? Zunächst muss man zwei Dinge in Erfahrung bringen:</p>



<ul class="wp-block-list"><li>Den <strong>Namen </strong>des <strong>Resource-Providers </strong>um den es geht</li><li>Die <strong>Operationen </strong>auf diesem Provider, die man erlauben oder verbieten möchte</li></ul>



<span id="more-3893"></span>



<p>Dazu kann man sich in den Microsoft Docs informieren:</p>



<ul class="wp-block-list"><li> <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers?WT.mc_id=AZ-MVP-5001882">https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers</a>  &#8211; hier findet man die <strong>Resource Provider</strong> zu dein einzelnen Azure Services</li><li> <a href="https://docs.microsoft.com/de-de/azure/role-based-access-control/resource-provider-operations?WT.mc_id=AZ-MVP-5001882">https://docs.microsoft.com/de-de/azure/role-based-access-control/resource-provider-operations</a>  &#8211; und hier die auf den jeweiligen Resource Providern möglichen <strong>Operationen</strong></li></ul>



<p>Für den Fall der Virtual Machine finden wir dazu also:</p>



<ul class="wp-block-list"><li>Der Resource Provider heisst &#8222;<strong>Microsoft.Compute</strong>&#8222;</li><li>Auf diesem sind u.a. folgende Aktionen vorgesehen:<ul><li>Microsoft.Compute/virtualMachines/powerOff/action    <ul><li>Powers off the virtual machine. Note that the virtual machine will continue to be billed.</li></ul></li><li>Microsoft.Compute/virtualMachines/read            <ul><li>Get the properties of a virtual machine</li></ul></li><li> Microsoft.Compute/virtualMachines/restart/action    <ul><li>Restarts the virtual machine</li></ul></li><li> Microsoft.Compute/virtualMachines/start/action<ul><li>Starts the virtual machine</li></ul></li></ul></li></ul>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="336" src="https://www.hertes.net/wp-content/uploads/2020/02/image-1024x336.png" alt="" class="wp-image-3894" srcset="https://www.hertes.net/wp-content/uploads/2020/02/image-1024x336.png 1024w, https://www.hertes.net/wp-content/uploads/2020/02/image-300x99.png 300w, https://www.hertes.net/wp-content/uploads/2020/02/image-768x252.png 768w, https://www.hertes.net/wp-content/uploads/2020/02/image-1536x505.png 1536w, https://www.hertes.net/wp-content/uploads/2020/02/image.png 2045w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="536" src="https://www.hertes.net/wp-content/uploads/2020/02/image-1-1024x536.png" alt="" class="wp-image-3895" srcset="https://www.hertes.net/wp-content/uploads/2020/02/image-1-1024x536.png 1024w, https://www.hertes.net/wp-content/uploads/2020/02/image-1-300x157.png 300w, https://www.hertes.net/wp-content/uploads/2020/02/image-1-768x402.png 768w, https://www.hertes.net/wp-content/uploads/2020/02/image-1-1536x804.png 1536w, https://www.hertes.net/wp-content/uploads/2020/02/image-1-2048x1072.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Die Liste der möglichen Aktionen auf einem Resource Provider kann man auch via PowerShell bekommen, z.B.:</p>



<p><pre lang="PowerShell" line="1">Get-AzProviderOperation "Microsoft.Compute/*" | FT Operation, Description -AutoSize</pre></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="208" src="https://www.hertes.net/wp-content/uploads/2020/02/image-2-1024x208.png" alt="" class="wp-image-3896" srcset="https://www.hertes.net/wp-content/uploads/2020/02/image-2-1024x208.png 1024w, https://www.hertes.net/wp-content/uploads/2020/02/image-2-300x61.png 300w, https://www.hertes.net/wp-content/uploads/2020/02/image-2-768x156.png 768w, https://www.hertes.net/wp-content/uploads/2020/02/image-2-1536x311.png 1536w, https://www.hertes.net/wp-content/uploads/2020/02/image-2-2048x415.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Man muss allerdings berücksichtigen, dass es zum Starten einer VM auch erstmal nötig ist, die VM überhaupt sehen zu dürfen&#8230;</p>



<p>Als nächstes muss man die Rollen-Definition im JSON-Format schreiben. Dazu kann man sich auch vorab eine bereits existierende Rollendefinition herunterladen, z.B. mit</p>



<p><pre lang="PowerShell" line="1">Get-AzRoleDefinition -Name "Virtual Machine Contributor" | ConvertTo-Json</pre></p>



<p>Nun passt man sich das JSON so an, dass die gewünschten Aktionen abgedeckt sind. Dabei wird die &#8222;ID&#8220; Zeile entfernt und &#8222;IsCustom&#8220; auf &#8222;true&#8220; gesetzt. Außerdem muss der AssignableScope gesetzt werden. In unserem Fall führt das in etwa zu dieser Definition:</p>



<p><pre lang="Javascript" line="1">
{
  "Name": "Virtual Machine Starter-Stopper",
  "IsCustom": true,
  "Description": "Lets you see, start, restart and stop Virtual Machines.",
  "Actions": [
	"Microsoft.Resources/subscriptions/resourceGroups/read",
    "Microsoft.Compute/virtualMachines/read",
	"Microsoft.Compute/virtualMachines/start/action",
	"Microsoft.Compute/virtualMachines/restart/action",
	"Microsoft.Compute/virtualMachines/powerOff/action",
	"Microsoft.Compute/virtualMachines/deallocate/action"
  ],
  "NotActions": [],
  "DataActions": [],
  "NotDataActions": [],
  "AssignableScopes": [
    "/subscriptions/00000000-1234-5678-91234-000000000000"
  ]
}
</pre></p>



<p>Diese Definition kann man z.B. mit vi in der Azure Cloud Shell in ein File schreiben. Diese kann man dann wiederum mit </p>



<p><pre lang="PowerShell" line="1">New-AzRoleDefinition -InputFile myRole.json</pre></p>



<p>in eine neue Rolle schreiben lassen.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="339" src="https://www.hertes.net/wp-content/uploads/2020/02/image-3-1024x339.png" alt="" class="wp-image-3898" srcset="https://www.hertes.net/wp-content/uploads/2020/02/image-3-1024x339.png 1024w, https://www.hertes.net/wp-content/uploads/2020/02/image-3-300x99.png 300w, https://www.hertes.net/wp-content/uploads/2020/02/image-3-768x254.png 768w, https://www.hertes.net/wp-content/uploads/2020/02/image-3-1536x508.png 1536w, https://www.hertes.net/wp-content/uploads/2020/02/image-3.png 1963w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Nun kann man die Rolle bspw. über das Azure Portal zuweisen:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="755" height="1024" src="https://www.hertes.net/wp-content/uploads/2020/02/image-4-755x1024.png" alt="" class="wp-image-3899" srcset="https://www.hertes.net/wp-content/uploads/2020/02/image-4-755x1024.png 755w, https://www.hertes.net/wp-content/uploads/2020/02/image-4-221x300.png 221w, https://www.hertes.net/wp-content/uploads/2020/02/image-4-768x1042.png 768w, https://www.hertes.net/wp-content/uploads/2020/02/image-4.png 896w" sizes="auto, (max-width: 755px) 100vw, 755px" /></figure>



<p>Und damit kann der Benutzer dann genau die definierten Rechte wahrnehmen &#8211; und nicht mehr!</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="345" src="https://www.hertes.net/wp-content/uploads/2020/02/image-5-1024x345.png" alt="" class="wp-image-3900" srcset="https://www.hertes.net/wp-content/uploads/2020/02/image-5-1024x345.png 1024w, https://www.hertes.net/wp-content/uploads/2020/02/image-5-300x101.png 300w, https://www.hertes.net/wp-content/uploads/2020/02/image-5-768x259.png 768w, https://www.hertes.net/wp-content/uploads/2020/02/image-5-1536x518.png 1536w, https://www.hertes.net/wp-content/uploads/2020/02/image-5-2048x690.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Viel Spaß beim Ausprobieren!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hertes.net/2020/02/azure-rbac-custom-role-fuer-das-starten-und-stoppen-von-vms/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
