Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Med den här snabbstarten kan du skapa ett Azure AI Video Indexer-konto (VI) med hjälp av Bicep.
Följande resurser installeras med Bicep-mallen:
- Azure Storage-konto. Lagringskonton för VI måste vara ett standardlagringskonto för generell användning v2.
- VI-konto anslutet till lagringskontot med hjälp av en systemtilldelad hanterad identitet
- Rolltilldelningen för rollen Storage Blob Data Contributor för VI-kontot på lagringskontot
Förutsättningar
- En Azure-prenumeration med behörighet att skapa resurser.
- Den senaste versionen av Azure CLI.
- Rekommenderas: Verktyg för Bicep.
Granska Bicep-filen
Koden som medföljer den här snabbstarten finns i de officiella Azure AI Video Indexer-exemplen.
Filen main.bicep
samordnar installationen av två moduler:
- VI-modulen som distribuerar VI-kontot med dess beroende Azure Storage-kontoresurs.
- Rollbehörighetsmodulen som ger VI-identitetens Azure Blob Storage Data Owner-behörighet på lagringskontot.
Kommentar
Det är en bra idé att separera Azure-resurser till flera Bicep-moduler. En omfattande förståelse för hur Bicep-moduler fungerar finns i Bicep-moduler – Azure Resource Manager.
Skapa Bicep-filen
Kopiera och klistra in följande innehåll i en fil med namnet main.bicep i arbetskatalogen.
param location string = resourceGroup().location @description('Storage Account Name') param storageAccountName string = “<add_your_storage_account_name” @description('Video Indexer Account Name') param videoIndexerAccountName string = = “<add_your_videoindexer_account_name>” module videoIndexer 'videoIndexer.bicep' = { name: 'videoIndexer.bicep' params: { location: location storageAccountName: storageAccountName videoIndexerAccountName: videoIndexerAccountName } } // Role Assignment must be on a separate resource module roleAssignment 'role-assignment.bicep' = { name: 'grant-storage-blob-data-contributor' params: { servicePrincipalObjectId: videoIndexer.outputs.servicePrincipalId storageAccountName: storageAccountName } dependsOn: [ videoIndexer ] }
main.bicep
Redigera filen genom att fylla i parametrarna som saknas:- storageAccountName – namnet på det lagringskonto som du vill ansluta till Azure AI Video Indexer-kontot
- videoIndexerAccountName – VI-kontonamnet
Skapa en Bicep-modul för Video AI-indexering
Kopiera och klistra in följande innehåll i en fil med namnet videoindexer.bicep i arbetskatalogen. Filen distribuerar lagringskontot tillsammans med ett VI-konto med en systemtilldelad identitet.
param location string = resourceGroup().location
@description('Storage Account Name')
param storageAccountName string
@description('Video Indexer Account Name')
param videoIndexerAccountName string
@description('Storage Account Kind')
var storageKind = 'StorageV2'
@description('Storage Account Sku')
var storageSku = 'Standard_LRS'
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
name: storageAccountName
location: location
kind: storageKind
properties: {
minimumTlsVersion: 'TLS1_2'
}
sku: {
name: storageSku
}
}
resource videoIndexer 'Microsoft.VideoIndexer/accounts@2024-01-01' = {
name: videoIndexerAccountName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
storageServices: {
resourceId: storageAccount.id
}
}
}
output storageAccountName string = storageAccount.name
output accountName string = videoIndexer.name
output servicePrincipalId string = videoIndexer.identity.principalId
Skapa en modul för rolltilldelning i Bicep
Kopiera och klistra in följande innehåll i en fil som heter role-assignment.bicep
i arbetskatalogen. Modulen tilldelar den systemtilldelade identiteten rollen som Storage Blob Data Contributor på lagringskontot i VI-kontot.
@secure()
param servicePrincipalObjectId string
param storageAccountName string
@description('Storage Blob Data Contributor Role Id')
var storageBlobDataContributorRoleId = 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' existing= {
name: storageAccountName
}
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
name: guid(storageAccount.id, servicePrincipalObjectId, 'Storage Blob Data Contributor')
scope: storageAccount
properties: {
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', storageBlobDataContributorRoleId)
principalId: servicePrincipalObjectId
principalType: 'ServicePrincipal'
}
}
Distribuera Bicep-filerna
Öppna en terminal och se till att du är inloggad på din Azure-prenumeration.
az login
az account set --subscription <your-subscription-name>
Skapa en resursgrupp.
az group create -n <your-resource-group-name> -l eastus
Distribuera mallen till resursgruppen.
az deployment group create --resource-group <your-resource-group-name> --template-file .\main.template.json
Vänta tills distributionen har slutförts och inspektera den skapade resursen på Azure Portal.
Relaterade artiklar
Om du inte har använt Azure AI Video Indexer tidigare kan du läsa:
- Dokumentation om Azure AI Video Indexer
- Utvecklarportalen för Azure AI Video Indexer
- De officiella exemplen för Azure AI Video Indexer
Om du är ny på Bicep-implementering, se: