Skip to content

Commit 762fdfc

Browse files
Update 5-access-package.md
1 parent 520002d commit 762fdfc

File tree

1 file changed

+2
-34
lines changed

1 file changed

+2
-34
lines changed

articles/governance/machine-configuration/how-to/develop-custom-package/5-access-package.md

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,10 @@ This page provides a guide on how to provide access to Machine Configuration pac
1515
## Steps to provide access to the package
1616
### Using a User Assigned Identity
1717

18-
**1. Obtain a User-Assigned Managed Identity:**
1918
> [!IMPORTANT]
20-
> Please note that, unlike Azure VMs, Arc-connected machines currently do not support User Assigned Managed Identities.
19+
> Please note that, unlike Azure VMs, Arc-connected machines currently do not support User-Assigned Managed Identities.
2120
22-
To start, you need to obtain the existing resourceId a user-assigned managed identity or create a new. This identity will be used by your VMs to access the Azure storage blob. The following PowerShell command creates a new user-assigned managed identity in the specified resource group:
23-
```powershell
24-
$identity = New-AzUserAssignedIdentity -ResourceGroupName "YourResourceGroup" -Name "YourIdentityName"
25-
```
26-
You can also retrieve the resource ID of the user-assigned managed identity that has access to the storage account.
27-
```powershell
28-
$managedIdentityResourceId = (Get-AzUserAssignedIdentity -ResourceGroupName "YourResourceGroup" -Name "YourManagedIdentityName").Id
29-
```
30-
31-
**2. Assign the Managed Identity to Your Azure VMs:**
32-
Next, you need to assign the created managed identity to your VMs. This allows the VMs to use the identity for accessing resources. The following command retrieves the VM and assigns the user-assigned identity to it:
33-
```powershell
34-
$vm = Get-AzVM -ResourceGroupName "YourResourceGroup" -Name "YourVMName"
35-
Set-AzVM -ResourceGroupName "YourResourceGroup" -VMName "YourVMName" -IdentityType UserAssigned -UserAssignedIdentityId $identity.Id
36-
```
37-
38-
**3. Grant the Managed Identity Access to the Blob Storage:**
39-
Now, you need to grant the managed identity read access to the Azure storage blob. This involves assigning the “Storage Blob Data Reader” role to the identity at the scope of the blob container. The following commands retrieve the storage account and create the role assignment:
40-
```powershell
41-
$storageAccount = Get-AzStorageAccount -ResourceGroupName "YourResourceGroup" -Name "YourStorageAccountName"
42-
$scope = $storageAccount.Id + "/blobServices/default/containers/YourContainerName"
43-
New-AzRoleAssignment -ObjectId $identity.PrincipalId -RoleDefinitionName "Storage Blob Data Reader" -Scope $scope
44-
```
45-
46-
**4. Access the Blob Storage from the VMs:**
47-
Finally, from within your VM, you can use the managed identity to access the blob storage. The following commands create a storage context using the connected account and retrieve the blob from the specified container:
48-
```powershell
49-
$context = New-AzStorageContext -StorageAccountName "YourStorageAccountName" -UseConnectedAccount
50-
$blob = Get-AzStorageBlob -Container "YourContainerName" -Blob "YourBlobName" -Context $context
51-
```
52-
53-
This setup ensures that your Azure VMs can securely read from the specified blob container using the user-assigned managed identity.
21+
You can grant private access to a machine configuration package in an Azure Storage blob by assigning a User-Assigned Identity to a scope of Azure VMs that you wish to apply the package to. For this to work, you need to grant the managed identity read access to the Azure storage blob. This involves assigning the “Storage Blob Data Reader” role to the identity at the scope of the blob container. This setup ensures that your Azure VMs can securely read from the specified blob container using the user-assigned managed identity.
5422

5523
### Using a SAS Token
5624
While this next step is optional, you should add a shared access signature (SAS) token in the URL to ensure secure access to the package. The below example generates a blob SAS token with read access and returns the full blob URI with the shared access signature token. In this example, the token has a time limit of three years.

0 commit comments

Comments
 (0)