Atribua uma identidade gerenciada atribuída pelo usuário a um Microsoft Planetary Computer Pro GeoCatalog por meio da CLI

Este guia mostra como usar a CLI (Interface de Linha de Comando) do Azure por meio do terminal de comando de sua escolha para atribuir uma identidade gerenciada a um recurso GeoCatalog.

Selecione a guia PowerShell ou Bash para atribuir a identidade gerenciada.

Usar o PowerShell para atribuir uma identidade gerenciada atribuída pelo usuário

# Define variables (Replace these with your specific values)
# Subscription ID: Your Azure subscription ID
$SUBSCRIPTION_ID = "{your-subscription-id}" # <-- Modify this line

# Resource Group: The name of the resource group where the GeoCatalog will be updated
$RESOURCE_GROUP = "{your-resource-group}" # <-- Modify this line

# GeoCatalog Name: The name of the GeoCatalog
$GEOCATALOG_NAME = "{your-geocatalog-name}" # <-- Modify this line

# Location: The Azure region where the GeoCatalog will be located
$LOCATION = "{your-location}" # <-- Modify this line

# Identity Name: The name of the user-assigned managed identity
$IDENTITY_NAME = "{your-identity-name}" # <-- Modify this line

# Tier: The tier of the GeoCatalog
$TIER = "Basic"

# Construct the user-assigned identity URI
$USER_ASSIGNED_IDENTITY = "/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.ManagedIdentity/userAssignedIdentities/$IDENTITY_NAME"

# Use the Azure CLI to create or update a GeoCatalog with the specified properties
az rest --method PUT `
  --uri "https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.Orbital/geoCatalogs/${GEOCATALOG_NAME}?api-version=2025-02-11-preview" `
  --headers "Content-Type=application/json" `
  --body "{'location': '$LOCATION', 'Properties': {'tier': '$TIER'}, 'identity': {'type': 'UserAssigned', 'userAssignedIdentities': {'$USER_ASSIGNED_IDENTITY': {}}}}"

Salvar o script para o PowerShell

  1. Salve o script com uma .ps1 extensão. Por exemplo, assign_identity.ps1.
  2. Abra um editor de texto, por exemplo, o Bloco de Notas ou o VS Code, e cole o script no editor.
  3. Salve o arquivo com a .ps1 extensão.

Substitua as variáveis

  1. Abra o arquivo de script salvo em um editor de texto.
  2. Substitua os valores de espaço reservado no script por seus valores específicos:
    • {your-subscription-id}
    • {your-resource-group}
    • {your-geocatalog-name}
    • {your-location}
    • {your-identity-name}
  3. Certifique-se de substituir todas as ocorrências desses espaços pelos valores reais.

Executar o script

Depois de salvar o script e substituir as variáveis, execute-o usando o seguinte comando:

.\assign_identity.ps1

Uma vez concluído, prossiga para as instruções Conceder permissões de leitura de Identidade Gerenciada atribuída pelo usuário no Armazenamento de Blobs do Azure.