Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Azure üzerinde yeni kaynaklar oluşturmanın birçok yolu vardır. Bicep dosyaları, Azure kaynaklarını tanımlamak için deklaratif, modüler ve yeniden kullanılabilir bir yaklaşım sunar. Bicep şablonları, JSON tabanlı ARM şablonları veya PowerShell ve Azure CLI gibi zorlayıcı betik yöntemlerine kıyasla Azure Kaynak Yöneticisi (ARM) ile daha iyi okunabilirlik, sürdürülebilirlik ve yerel entegrasyon sunar. GitHub Copilot for Azure, Bicep dosyaları oluşturmanıza yardımcı olabilir.
Bicep dosyaları oluştur
Bicep dosyalarıyla çalışmaya başlamak, sözdizimi konusunda yeniyseniz biraz öğrenme gerektirebilir, ancak Azure için GitHub Copilot gibi araçlar yardımcı olabilir.
Örnek senaryo
Diyelim ki, bir Blob kapsayıcısı ve dosya paylaşımı oluşturmak için tekrarlanabilir, otomatik bir süreç oluşturmanın kolay bir yolunu istiyorsunuz. Azure portalunu kullanarak bir Blob konteyneri ve dosya paylaşımı oluşturmayı biliyor olabilirsiniz, ancak aynı görevi gerçekleştirmek için Bicep dosyalarını nasıl kullanacağınızdan emin değilsiniz.
Örnek komut
Yeni bir sohbet oluşturun (Ctrl + L), ardından aşağıdaki istemi GitHub Copilot'un sohbet alanına kopyalayın ve yapıştırın.
Show me a Bicep file that creates an Azure Storage account with a blob container and a file share.
Örnek yanıt
Uyarı
Aşağıdaki yanıt bir örnektir. GitHub Copilot for Azure yanıtları belirli bir düzene sahip değildir, bu yüzden burada gösterilenden farklı bir yanıt alabilirsiniz.
Azure için GitHub Copilot, aşağıdakine benzer bir Bicep dosyası oluşturur.
@description('Specifies the name of the Azure Storage account.')
param storageAccountName string
@description('Specifies the name of the blob container to create.')
param blobContainerName string
@description('Specifies the name of the file share to create.')
param fileShareName string
@description('Specifies the location in which the Azure Storage resources should be deployed.')
param location string = resourceGroup().location
resource sa 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
}
}
resource blobServices 'Microsoft.Storage/storageAccounts/blobServices@2023-01-01' = {
parent: sa
name: 'default'
}
resource blobContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2023-01-01' = {
parent: blobServices
name: blobContainerName
properties: {
publicAccess: 'None'
}
}
resource fileServices 'Microsoft.Storage/storageAccounts/fileServices@2023-01-01' = {
parent: sa
name: 'default'
}
resource fileShare 'Microsoft.Storage/storageAccounts/fileServices/shares@2023-01-01' = {
parent: fileServices
name: fileShareName
properties: {
shareQuota: 100 // Quota in MB
}
}
Yeni bir main.bicep dosyası oluşturun, ardından Azure için GitHub Copilot'tan gelen yanıtı kopyalayarak yeni dosyaya yapıştırın.
Azure CLI kullanarak Bicep dosyasını çalıştırırken, storageAccountName, blobContainerName, ve fileShareName olarak belirtilen parametreleri ayarlayabilirsiniz.
Alternatif olarak, storageAccountName parametresini istediğiniz değere ayarlayarak Bicep dosyasını düzenleyebilirsiniz.
param storageAccountName string = '<your-storage-account-name>'
Yanıtı düzelt
Ancak, Bicep dosyalarına yeniyseniz, daha fazla bilgiye ihtiyaç duyabilirsiniz. Aynı sohbet oturumunda devam ederek sonraki adımları anlamaya çalışın.
Örneğin, bu Bicep dosyasının VS Code çalışma alanınızda nereye oluşturulması gerektiğini sormak isteyebilirsiniz.
Where in my workspace should I create the Azure Bicep file, and what should I call it?
Bicep dosyanız için bir klasör ve dosya adı önererek yanıt verebilir. Örneğin, infra/storageAccount.bicep.
Son olarak, Bicep dosyasını nasıl dağıtacağınız konusunda emin değilseniz, talimat isteyecek bir komut oluşturabilirsiniz.
How do I execute the Azure Bicep file?
Aşağıdakine benzer bir yanıt alabilirsiniz.
To execute the Bicep file, you can use the Azure CLI with the following steps:
1. **Install Azure CLI and Bicep CLI**: Ensure you have the Azure CLI and Bicep CLI installed. You can install Bicep using the Azure CLI with the command:
az bicep install
2. **Log in to Azure**: Use the Azure CLI to log in to your Azure account:
az login
3. **Deploy the Bicep file**: Use the `az deployment group create` command to deploy the Bicep file to a resource group. Replace `<resource-group-name>` with your resource group name and `<location>` with your desired Azure region:
az deployment group create --resource-group <resource-group-name> --template-file infra/storageAccount.bicep --parameters storageAccountName=<your-storage-account-name> containerName=<your-container-name> fileShareName=<your-file-share-name> location=<location>
This command will deploy the resources defined in your Bicep file to the specified resource group in Azure.
Bu yönergeleri izlerken, takılırsanız veya bir sorunla karşılaşırsanız sohbet bölmesindeki sözcük azure de dahil olmak üzere istemler oluşturarak GitHub Copilot'a sorular sormaya devam edin.