0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Bicep実行時にEnvironment URLs should not be hardcoded. Use the environment() の警告に対応したメモ

Posted at

概要

下記のエラーが発生。

Warning no-hardcoded-env-urls: Environment URLs should not be hardcoded. Use the environment() function to ensure compatibility across clouds. Found this disallowed host: "core.windows.net" [https://aka.ms/bicep/linter/no-hardcoded-env-urls]

ソースコード

対応

コメント*にあるように、environment()から取得できるsuffixを使用すれば警告は解消される。

  {
    name: 'TARGET_STORAGE_ACCOUNT__blobServiceUri'
-    value: 'https://${uploadStroageAccountName}.blob.core.windows.net'
+    value: 'https://${uploadStroageAccountName}.blob.${environment().suffixes.storage}'
  }
  {
    name: 'DATABASE_CONNECTION_STRING'
-    value: 'Server=tcp:${sqlServerName}.database.windows.net;Authentication=Active Directory Default; Database=${sqlServerDbName};'
+    value: 'Server=tcp:${sqlServerName}${environment().suffixes.sqlServerHostname};Authentication=Active Directory Default; Database=${sqlServerDbName};'
  }

注意点

suffixによって、頭の.の有無が異なる。なんで。
suffixes

key value .の有無
acrLoginServer .azurecr.io あり
azureDatalakeAnalyticsCatalogAndJob azuredatalakeanalytics.net
azureDatalakeStoreFileSystem azuredatalakestore.net
azureFrontDoorEndpointSuffix azurefd.net
keyvaultDns .vault.azure.net あり
sqlServerHostname .database.windows.net あり
storage core.windows.net

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?