Self-Hosted Guide for Azure #4858
Replies: 3 comments 9 replies
-
To self-host the Dify application in Azure, you need to configure various environment variables and settings. Here are the key steps and configurations you need to set up:
Additionally, you need to configure the hosting provider settings in your application. For Azure OpenAI, you can enable and configure it as follows: class HostingConfiguration:
provider_map: dict[str, HostingProvider] = {}
moderation_config: HostedModerationConfig = None
def init_app(self, app: Flask) -> None:
config = app.config
if config.get('EDITION') != 'CLOUD':
return
self.provider_map["azure_openai"] = self.init_azure_openai(config)
self.provider_map["openai"] = self.init_openai(config)
self.provider_map["anthropic"] = self.init_anthropic(config)
self.provider_map["minimax"] = self.init_minimax(config)
self.provider_map["spark"] = self.init_spark(config)
self.provider_map["zhipuai"] = self.init_zhipuai(config)
self.moderation_config = self.init_moderation_config(config)
def init_azure_openai(self, app_config: Config) -> HostingProvider:
quota_unit = QuotaUnit.TIMES
if app_config.get("HOSTED_AZURE_OPENAI_ENABLED"):
credentials = {
"openai_api_key": app_config.get("HOSTED_AZURE_OPENAI_API_KEY"),
"openai_api_base": app_config.get("HOSTED_AZURE_OPENAI_API_BASE"),
"base_model_name": "gpt-35-turbo"
}
quotas = []
hosted_quota_limit = int(app_config.get("HOSTED_AZURE_OPENAI_QUOTA_LIMIT", "1000"))
trial_quota = TrialHostingQuota(
quota_limit=hosted_quota_limit,
restrict_models=[
RestrictModel(model="gpt-4", base_model_name="gpt-4", model_type=ModelType.LLM),
RestrictModel(model="gpt-4-32k", base_model_name="gpt-4-32k", model_type=ModelType.LLM),
RestrictModel(model="gpt-4-1106-preview", base_model_name="gpt-4-1106-preview", model_type=ModelType.LLM),
RestrictModel(model="gpt-4-vision-preview", base_model_name="gpt-4-vision-preview", model_type=ModelType.LLM),
RestrictModel(model="gpt-35-turbo", base_model_name="gpt-35-turbo", model_type=ModelType.LLM),
RestrictModel(model="gpt-35-turbo-1106", base_model_name="gpt-35-turbo-1106", model_type=ModelType.LLM),
RestrictModel(model="gpt-35-turbo-instruct", base_model_name="gpt-35-turbo-instruct", model_type=ModelType.LLM),
RestrictModel(model="gpt-35-turbo-16k", base_model_name="gpt-35-turbo-16k", model type=ModelType.LLM),
RestrictModel(model="text-davinci-003", base_model_name="text-davinci-003", model type=ModelType.LLM),
RestrictModel(model="text-embedding-ada-002", base_model_name="text-embedding-ada-002", model type=ModelType.TEXT_EMBEDDING),
RestrictModel(model="text-embedding-3-small", base_model_name="text-embedding-3-small", model type=ModelType.TEXT_EMBEDDING),
RestrictModel(model="text-embedding-3-large", base_model_name="text-embedding-3-large", model type=ModelType.TEXT_EMBEDDING),
]
)
quotas.append(trial_quota)
return HostingProvider(
enabled=True,
credentials=credentials,
quota_unit=quota_unit,
quotas=quotas
)
return HostingProvider(
enabled=False,
quota_unit=quota_unit,
) After setting these environment variables and configuring the hosting provider, you can deploy your application to Azure using Docker or other deployment methods supported by Azure [1][2]. |
Beta Was this translation helpful? Give feedback.
-
https://docs.dify.ai/getting-started/install-self-hosted/docker-compose @rachaelsingleton It can be easily started by docker. Just install the docker in azure machines, and follow the docs above. |
Beta Was this translation helpful? Give feedback.
-
Sure, followed the steps but there's issue after issue that keeps coming up. I've set up Postgres and Redis in azure and updated the connection strings/env variables as required. I cannot get passed the install screen, it keeps cycling between signing up and logging in. There are no errors in the logs, and the only thing I have to go on is a 403 - 2024-06-03 10:36:10 nginx-1 | 172.23.0.1 - - [03/Jun/2024:14:36:10 +0000] "POST /console/api/setup HTTP/1.1" 403 154 "http://localhost/install" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0" "-" I've tried to pull out each service individually and I believe it's when the postgres DB is set up in azure. |
Beta Was this translation helpful? Give feedback.
-
Self Checks
Provide a description of requested docs changes
Looking for a guide to self-host in Azure.
Beta Was this translation helpful? Give feedback.
All reactions